Loading...

Knowledge Base

Document Root Changes

Did you find this article helpful?
Copy Link

 
* Your feedback is too short
Share

 

Updating the document root folder of a domain name changes the actual location of a site's files. Your primary domain uses the public_html folder by default. Please note that there is no real benefit in changing the current addon domain's document root unless it is strictly for "visual purposes" or if it's required for site development. If it's not really required, it is better to keep the current document root to prevent breaking the site.

HostGator does not support changing the document root for your main (primary) domain, as this causes multiple severe issues. The document root can only be changed for addon domains and subdomains.

This article discusses the following topics:


How to modify the document root for an addon domain or subdomain

The directories or folders of addon domains and/or subdomains are created within the home directory of the cPanel.

Note: HostGator always recommends creating a full backup before making any major changes to your website, like changing your site folder's document root.

To change the document root folder:

  1. Log in to cPanel. There are two ways to access your cPanel.
    • Option 1: Access your cPanel directly.
    • Option 2: Access your cPanel via your Customer Portal.
      1. Log in to your Customer Portal.
      2. Click Hosting in the left-side menu.

        Customer Portal - Hosting menu

      3. If you have a single hosting package in your account, scroll down to the Quick Links section.


        If you have multiple hosting packages in your account, locate the hosting package you want to manage on the Hosting Packages page, then click its Manage button.

        Hosting tab - Manage button

      4. Under the Quick Links section, click the cPanel button.

        Hosting menu - Quick Links - Launch cPanel

  2. In the Domains section, click on Domains.

    cPanel - Domains

  3. Locate the addon domain (or subdomain) you wish to modify, then click on the Manage button.

    cPanel - Manage Domains

  4. Update the document root under New Document Root.

    cPanel - Enter new document root

  5. Once done, click Update.

The document root should immediately reflect the update. Please move the site's contents into the new document root so the server will know where to search for your website's contents.


Alternatives to changing the document root for the primary domain

If you still want your primary domain to use a root folder other than public_html, you have two options:

  • Change the primary domain name on your account, then add the old primary domain as an addon domain. This way, you can pick the root folder you want for the primary domain/new addon domain. (The new primary domain will now point to public_html.)
    Note: You need to manually move the contents of the old primary domain into its new folder after you add the domain as an addon domain.
  • Use mod rewrite to automatically redirect your website visitors to a new default directory. The new folder name will appear in the URL (i.e., http://domainname.com/subfolder/).
It is highly recommended that you don't change your new document root to point to your home directory.

 

Did you find this article helpful?
Copy Link

 
* Your feedback is too short

Loading...