Hosting glossarypublic_html is the folder on many hosting accounts that holds the files for the main website. Whatever is inside it is publicly reachable on the web.
public_html is the document root on cPanel and many other shared hosting accounts: the folder the web server serves the main domain from. A file at public_html/about.html is available at example.com/about.html, and a folder inside it becomes a path on the site. Anything outside public_html, in the rest of the account's home directory, cannot be reached from the web.
On a typical cPanel account the full path is /home/username/public_html. A folder called www often sits beside it; it is a symbolic link to public_html, so both names lead to the same files.
What lives there on a WordPress site
When WordPress is installed on the main domain, its files go straight into public_html: wp-admin, wp-content (themes, plugins, and uploads), wp-includes, wp-config.php, index.php, and the .htaccess file. When someone visits the domain, the server looks for an index file, such as index.php or index.html, and serves that.
Addon domains and subdomains get folders of their own, often inside public_html and sometimes beside it, depending on the host's settings.
Other names for the same thing
The web root goes by different names on other setups: htdocs, www, httpdocs on Plesk, or /var/www/html on many Linux servers. The idea is the same everywhere: one folder is public, the rest of the account is not.
How to get to it
- cPanel File Manager: log in to the control panel, open File Manager, and public_html is in the home directory.
- SFTP: connect with an SFTP client using your hosting credentials.
- SSH: on hosts that allow it,
cd ~/public_html.
Common mistakes
- Leaving backups in it. A
.zipof the site or a.sqldatabase dump inside public_html can be downloaded by anyone who guesses the name, along with every password inside. Keep backups outside the web root or off the server. - Directory listings. A folder with no index file may show a list of its contents. Many hosts turn this off; on Apache,
Options -Indexesin.htaccessdoes it. - Loose permissions. WordPress recommends 755 for folders and 644 for files; 777 lets any process on the server change them. See file permissions.
- Deleting it. Removing or renaming public_html takes the main site offline.
Keeping private files out of the web root is good practice. WordPress, for example, will also find wp-config.php if it is moved one folder above the installation, outside public_html.