What is a Document Root?
The Document Root directory is the designated folder path that the web server searches within for web content. This guide is great to know if you plan to upload files & subfolders for a website either through the File Manager or (S)FTP. There are some details to be aware of..
When a cPanel is created, it has a default Document Root for the Primary domain example.com located at the following path.
/home/examp12/public_html/
Creating a folder, or subfolder, alone via (S)FTP or File Manager does not automatically make it a Document Root. There must be a cPanel & web server mapping between the (sub)domain name (foo.)example.com to the designated Document Root folder path.
When adding either a Addon domain or Subdomain they will each have their own corresponding Document Root directories which can be configured from the Addon Domains, Subdomains, or the Domains features within the Domains section of cPanel.
Where is a domain's Document Root set in cPanel?
For the following example this guide will be using the Addon Domains feature of cPanel, however the same process can apply to the Subdomains feature as well. The Domains feature has a slightly different process which will be covered further along in the article.
Notice the icon from the image below, this icon represents the default path to the cPanel's home directory /home/examp12/. Most commonly, a cPanel username such as 'examp12' is the shortened version of the Primary domain example.com from when the cPanel account was first created.
When entering the new Addon domain name into the New Domain Name text field, the Subdomain name & Document Root path will be automatically generated after typing the domain name. Suppose your Addon domain is called myexample2.com, then the Document Root path will default to '/home/examp12/myexample2.com'
/home/examp12/
/home/examp12/myexample2.com
You can change the default path of the Document Root to something more custom.
For example, you want to add myexample2.com and have the web server search inside the /home/examp12/public_html/myexample2.com/ directory, then you would change the Document Root text field as
public_html/myexample2.com/
-
-
- You cannot use the following directories as a document root directory:
-
- The account’s home directory itself (
/
) - Directories outside of the account’s home directory (
./
and../
) .cpanel
.trash
etc
mail
ssl
tmp
logs
.cphorde
.spamassassin
.htpasswds
var
cgi-bin
.ssh
perl5
- The account’s home directory itself (
-
- You cannot use the following directories as a document root directory:
-
What if I already added the domain, can I update the Document Root?
That is no problem. You can update the Document Root path from the Addon Domains, Subdomains, and Domains feature pages.
Addon & Subdomain:
For the Addon & Subdomain pages you will want to look for the list of (sub)domains which have been already added, as shown below. Look to the second column for Document Root and click on the pencil to the right. This will open a popup in order to update the path.
You can see now the Document Root was updated to public_html/myexample2.com/ shorthand for /home/examp12/public_html/myexample2.com/.
Document Root on the Domains page:
To update the Document Root on the Domains page is a little different but overall similar in process. First, click on the Domains feature in cPanel. You should see the list of all domains including the Primary. There is a button to the right which states Create A New Domain, however for the example domain myexample2.com was already added in previous steps above so we'll be changing the Document Root back to it's original /home/examp12/myexample2.com/ directory.
Look to the far right for the Manage button.
You should now see the text box that allows you to edit the path of the Document Root. Retype the path to the correct folder you want then click the Update button. You can also Remove the domain as well if you wish.
Once updated the cPanel & web server will now search back to the folder
public_html/myexample2.com/
What if I want to update the Primary domain Document Root?
For this type of request it cannot be done through the cPanel but we can update this for you. You can reach out to our Support Team (support@reclaimhosting.com) and we can help make the switch. That's it!