The public_html directory is the web root of your website — every file you place here (and in its subdirectories) is accessible to visitors via your domain name. Understanding this structure is essential for managing your website in cPanel.
The public_html Directory
When visitors type your domain name (e.g., yourdomain.com) into their browser, the server loads the content from the public_html directory. This is where your website files live.
public_html/index.htmlorpublic_html/index.php— The default homepage. The server loads this file when someone visits your domain.public_html/404.html— Custom 404 error page displayed when a page is not found.public_html/.htaccess— Configuration file for URL rewrites, redirects, and Apache directives.
Key Files and Folders Explained
.htaccess— A hidden configuration file used by Apache. Common uses include:- URL rewriting (e.g., converting
page.php?id=1to/page/1). - Setting up 301 redirects.
- Enabling or disabling directory listings.
- Setting custom error pages.
- Security rules (blocking IPs, restricting access).
- URL rewriting (e.g., converting
wp-content/— The main WordPress directory containing themes, plugins, and uploads. Only present if WordPress is installed.wp-admin/— WordPress administration area. Do not modify unless you know what you are doing.wp-includes/— WordPress core files. Never modify these directly.cgi-bin/— Directory for CGI scripts. Used for server-side scripts that process forms or generate dynamic content..well-known/— Used for security and domain verification (e.g., SSL certificate validation, Apple app site association).
Subdomains and Addon Domains
cPanel creates subdomains and addon domains as subdirectories inside public_html:
- Subdomain (
blog.yourdomain.com) — Stored inpublic_html/blog/ - Addon domain (
anotherdomain.com) — Stored in a separate directory, oftenpublic_html/anotherdomain.com/ - Parked domain — Points to
public_html/(same content as the main domain).
Files Outside public_html
Files stored outside the public_html directory are not accessible via the web. This is useful for:
- Configuration files: Store sensitive settings (database credentials, API keys) above the web root for security.
- Backups: Store database backups or file archives where visitors cannot access them.
- Private scripts: Store scripts that should only be executed via cron jobs or SSH, not from a browser.
The typical cPanel home directory structure is:
/home/username/— Your cPanel home directory./home/username/public_html/— Your website (web-accessible)./home/username/mail/— Email storage (not web-accessible)./home/username/logs/— Access and error logs./home/username/etc/— Configuration files./home/username/.cpanel/— cPanel internal data (do not modify).
Important Notes
- Never delete or rename
public_htmlunless you intend to take your entire website offline. - Hidden files (starting with a dot, like
.htaccess) are not visible in File Manager by default. Enable "Show Hidden Files" in File Manager settings to see them. - Always back up
public_htmlbefore making significant changes to your website.
Troubleshooting
"Index of /" page showing instead of your website:
- Your
index.htmlorindex.phpfile is missing frompublic_html. - Create an
index.htmlorindex.phpfile with your homepage content.
Changes to files are not showing on the website:
- Clear your browser cache and reload the page.
- Check if you edited the correct file in
public_html. - If using a CDN or Cloudflare, purge the cache.
"Permission denied" when accessing files:
- Check the file permissions. Directories should be
755and files should be644.