How to change the primary domain document root

This article contains information about changing your default folder for your domain to be a sub-folder.


The main domain on the hosting account uses the public_html folder for all of its Web site files. Any addon domains use sub-folders inside the public_html folder. In order to also set up your main domain to use a sub-folder on your hosting account you will need to set up a redirect in the .htaccess file in the public_html folder so that the server knows that any request for your main domain will be redirected to a sub-folder on public_html.

Visitors to your Web site will not be able to tell that your main domain is using a sub-folder, they will still see the Web site address as http://www.yourdomain.com/page.html

# .htaccess main domain to subfolder redirect
# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.


# Do not change this line.

RewriteEngine on


# Change yourdomain.com to be your main domain.

RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$


# Change 'subfolder' to be the folder you will use for your main domain.

RewriteCond %{REQUEST_URI} !^/subfolder/

# Don't change this line.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Change 'subfolder' to be the folder you will use for your main domain.

RewriteRule ^(.*)$ /subfolder/$1

# Change yourdomain.com to be your main domain again.
# Change 'subfolder' to be the folder you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.

RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
RewriteRule ^(/)?$ subfolder/index.php [L]
  • 1 Utilisateurs l'ont trouvée utile
Cette réponse était-elle pertinente?

Articles connexes

How to configure/manage SpamAssassin?

SpamAssassin is an additional feature that we offer to our customers. If you would like to have...

How do I password protect a directory?

1) Log in to cPanel. 2) In the section called "Security" click "Password Protect...

How do I change my cPanel password?

1. Log into your Hostmetro cPanel account (yourdomain.com/cpanel). 2. Locate the Preferences...

Cron job setup

From the cPanel, go to Cron jobs, select Standard, and enter (between the quotes)...

How can I view statistics about my website?

All of Hostmetro's accounts come with a powerful statistic too call Awstats. This program...