Step 1: Access Your cPanel File Manager
- Log in to your web hosting account and navigate to the cPanel dashboard.
- Locate the “Files” section and click on the “File Manager” option.
- Ensure that you are in the “public_html” directory, which is the default document root for the main domain in cPanel.
Step 2: Create or Edit the .htaccess File
- Check if there is an existing .htaccess file in the “public_html” directory. If there is, proceed to step 3.
- If there is no .htaccess file, create one by clicking on the “Create” or “New File” button in the File Manager toolbar. Name the file “.htaccess” (including the period at the beginning) and save it in the “public_html” directory.
Step 3: Edit the .htaccess File to Change the Document Root
- Open the .htaccess file in the cPanel File Manager by right-clicking on it and selecting “Edit” or “Code Edit.”
- Add the following code to the .htaccess file:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.tld$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain.tld$
RewriteCond %{REQUEST_URI} !new-document-root/
RewriteRule (.*) /new-document-root/$1 [L]