What is a document root?
The document root is the folder where a website's files live. When someone visits your site, the server looks in that folder. By default, cPanel puts new addon domains and subdomains inside public_html, for example public_html/shop.
An addon domain is an extra website name on the same hosting account. A subdomain is a part of your main name, such as blog.example.com.
Some people prefer a folder outside public_html, like /home/username/mysite. It keeps sites apart, so the main site does not also serve the other site's files under its own address.
Steps
- Log in to cPanel.
- Open Domains. On older cPanel, open Addon Domains or Subdomains instead.
- Click Create A New Domain.
- Type the domain or subdomain name.
- Untick Share document root if you see it. This lets you choose your own folder.
- In the Document Root box, type the folder path without a starting slash. It is relative to your home folder. For example, type
mysiteinstead ofpublic_html/mysite. - Click Submit.
cPanel creates the folder in your home directory, next to public_html.
Change an existing domain
- Open Domains in cPanel.
- Find the domain in the list.
- Click Manage next to it.
- Find Document Root, click the edit option, and type the new folder.
- Save the change.
Warning: Changing the folder does not move your files. The site will show an empty page until you copy the files into the new folder. Take a backup first. Use File Manager to move the files.
Quick recap
- The document root is the folder a website is served from.
- In cPanel, use Domains and type a folder name that does not start with public_html.
- Existing files are not moved for you, so copy them over yourself.
- Back up before you change anything.