The public_html folder: where to put your website's files
On a cPanel hosting account, public_html is the folder that holds the files visible on the Internet. Everything in it can be seen by your visitors; the rest of your space stays private.
Before you start
- You can access cPanel or an FTP account (see the article "Publish your website by FTP with FileZilla").
- You know what you want to publish: an
index.htmlpage, a WordPress site, a folder of images…
What public_html is for
- The home directory is the top-level folder of your account. It holds all the files your sites use. According to the cPanel glossary, visitors cannot see anything it contains, except what is in
public_htmlor its subfolders. public_htmlis a subfolder of the home directory. It holds the files reachable over HTTP, that is, by the browser. Thewwwfolder is a link topublic_html.- The document root is the folder whose content is shown when someone types your domain's address. For the main domain, it defaults to
public_html.
In practice, the full path of public_html is /home/your-username/public_html. You will need it, for example, to schedule a cron job.
Steps: put your files in the right place
- Open the File Manager. In cPanel, under "Files", click File Manager. The Settings menu (at the top) lets you choose the folder opened at start: pick Web Root (public_html or www) to land directly in the right folder.
- Go into
public_html. In the left-hand column, clickpublic_html. - Drop your files. The Upload button sends files one by one. For a whole site, compress it to a
.zipon your computer, upload the archive, then select it and click Extract (see the article "Use the cPanel File Manager"). With FTP, openpublic_htmland drag your files into it. - Name the home page
index.html(orindex.php). According to the Apache documentation, the server looks for anindex.htmlfile in a folder by default; the exact name can be configured. A WordPress site brings its ownindex.php. - Check by opening your domain in the browser.
What about another domain?
When you add a domain or a subdomain, cPanel gives it its own folder, by default inside public_html (for example public_html/newdomain.com). That is where the domain's files go. You can see and change a domain's root in the Domains screen (Manage button), except for the main domain's. The folder does not move by itself: if you change the root, you must move your files yourself.
Expected result
Your site shows at your domain's address, and the files you do not want to publish (backups, configuration files) are somewhere other than public_html.
If something goes wrong
- Your domain shows a default page or a list of files. Your files are probably next to
public_html, or the home page file does not have the expected name (index.html, orindex.phpfor a PHP site). Check the folder and the name. - The
.htaccessfile is invisible. Files whose name starts with a dot are hidden. In the File Manager, Settings, tick Show Hidden Files (dotfiles). - A sensitive file is reachable online. Everything in
public_htmlis public, unless protected by a password or by.htaccess. Move it up, into the home directory. - After going live, the site has not changed. Clear your browser cache and check that you overwrote the right file.
FAQ
What is the full path of public_html?
It is /home/ followed by your cPanel username, then /public_html.
Can I put files outside public_html?
Yes, in the home directory, but they are then not reachable from the Internet. That is the place for anything that must not be public.
What is the difference between public_html and www?
None: according to the cPanel glossary, www is a link to public_html.
How should I organise my site's folders? Keep names simple (lower-case letters, digits, hyphens, no spaces or accents). This is not a cPanel requirement but it avoids hard-to-read addresses and mistakes.
Going further
Need a space to publish your site? See our web hosting.