The Document Root is the directory where the files for a particular domain or subdomain are stored on your server. By default, cPanel assigns a specific document root for each domain, typically within the public_html directory. Changing the document root can be useful if you want to point the domain to a different directory or manage multiple websites on the same hosting account.

In cPanel, you can modify the document root through the Addon Domains or Subdomains section. This flexibility allows you to configure different directories for different sites or environments (e.g., development vs. production). Changing the document root ensures that the domain or subdomain serves content from the correct folder.

Before changing the document root, make sure the new directory is properly configured and contains the necessary files for the domain. Incorrect configurations can result in the domain not displaying content correctly.

Steps to change the document root for a domain in cPanel:

  1. Log in to your cPanel account.
  2. Navigate to the Domains section.
  3. Click on Addon Domains if it's an addon domain or Subdomains if it's a subdomain.

    The document root can be changed for both addon domains and subdomains. Ensure you select the correct domain type.

  4. Find the domain or subdomain you want to modify.
  5. Click on Document Root next to the domain or subdomain.
  6. Enter the new directory path where you want to store the files for this domain.

    Make sure the new document root directory exists in your file structure or create it using the File Manager in cPanel.

    Example new document root:
    Old: /public_html/mydomain/
    New: /home/user/custom_directory/
  7. Click Save to apply the changes.

    Once the document root is changed, the domain will load files from the new directory. Test the domain after making the change to ensure it works as expected.

  8. Verify that the change has taken effect by visiting the domain in a browser.
Discuss the article:

Comment anonymously. Login not required.