Change Document Root in cPanel

Change Document Root in cPanel

There are two types of domains on a cPanel box that can have document roots: Main (primary) domains and Add-on domains.

Changing Primary domains

cPanel’s default primary domain’s document root is: /home/USERNAME/public_html. We need to configure your server/domain’s document root to the /home/USERNAME/public_html/public.

For changing the main/primary domain, you will need to have root SSH access, and be able to locate and edit the following file (replacing your user & domain info):


1. Once you open the file, look for the following line:

documentroot: /home/USERNAME/public_html

2. Modify the location like this:

documentroot: /home/USERNAME/public_html/public

3. Save it and exit.

4. Rebuild the Apache conf and restart Apache:

service httpd restart

The change will be immediate. Simply clear your browser cache and force refresh the page!


Changing Add-on Domain

Changing the document root for Add-on domains is easy. Simply log into your cPanel and navigate to: Domains >> Addon Domains.

Next, edit the Add-on domain path. To do so, simply click the “Edit” icon next to the path, and type in your new path. It’s that simple!


Creating a Sub-domain

If you want to use a sub-domain for this application. Just create the subdomain and set the path to the public_html/subdomian_directory/public To create a sub-domain, imply log into your cPanel and navigate to: Domains >> Subdomains.


Was this page helpful?

Leave Comment