HostMonster Web Hosting Help

How to host the Primary Domain from a subfolder (.htaccess)

Summary

The public_html directory for all of its Web site files. Addon domains use sub directories inside the public_html directory. In order to also set up your main domain to use a subdirectory 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 subdirectory on public_html.

Locating the .htaccess file in the File Manager

To begin you will need to open the .htaccess file located in your public_html folder. Because this file is, by default, not visible, please follow the instructions below to locate and open this file.

  1. Log in to the HostMonster cPanel.
  2. Scroll down to the Files section.
  3. Click the File Manager icon.
  4. Check the View Hidden Files checkbox.
  5. You are working with your primary domain, so select the WebRoot (public_html/www) option.
  6. Right click the .htaccess and choose Code Editor

Modifying the .htaccess

The following code will need to be added to the .htaccess file in the public_html folder of your hosting account. You will need to insert the following code block and make modifications as noted in the (#) comments.

You will need to change the two instances of example.com to your domain, and the three instances of subdirectory to the folder where you want your site.

# HostMonster.com
# .htaccess main domain to subdirectory redirect
# Do not change this line.
RewriteEngine on
# Change example.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subdirectory/
# Don't change the following two lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /subdirectory/$1
# Change example.com to be your main domain again.
# Change 'subdirectory' to be the directory 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.)?example.com$
RewriteRule ^(/)?$ subdirectory/index.html [L]

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

Please note that this will not work with some website software. You may also need to modify the $base_url, $live_site or other configuration settings to finish the process.

Joomla, Drupal and WordPress

If you are using Joomla, Drupal or WordPress it is recommend that you not follow the instructions above, rather that you follow the instructions provided by in the official documentation. Please see the links below for instructions specific to the CMS you are using.
Knowledgebase Article 302,617 views bookmark tags: Drupal domain htaccess joomla wordpress (updated 146 days ago)


Was this resource helpful?

Did this resolve your issue?


Please add any other comments or suggestions about this content:





Recommended Help Content

I do not want to see addon.maindomain.com. How do I do that? (updated 626 days ago)

Have FrontPage extensions and Wordpress installed on account. Was working fine in the past, but now cannot connect with FrontPage and Wordpress does not link properly. (updated 697 days ago)
Knowledgebase Article 62,345 views tags: frontpage htaccess wordpress

How do I stop people from being able to use the addon domain as a subdomain of the primary domain? (updated 636 days ago)
Knowledgebase Article 109,152 views tags: addon domain htaccess

Related Help Content

Wordpress Error: Unable to create directory /wp-content/uploads/2009/mydir/summer/ Is its parent directory writable by the server? (updated 1617 days ago)
Knowledgebase Article 32,368 views tags: create unable wordpress

When performing an upgrade (in this case, Joomla) in Simple Scripts, it can throw the following error: "Host Server Unresponsive Unfortunately, the server you are attempting to install on appears to b (updated 1617 days ago)
Knowledgebase Article 55,844 views tags: htaccess scripts simple

How to move WordPress from one folder to another folder on the same server. (updated 40 days ago)
Knowledgebase Article 7,021 views tags: migrate wordpress

How to Stop A Directory Index From Being Shown (updated 697 days ago)
Knowledgebase Article 79,895 views tags: directory htaccess index

How to install and activate a Drupal installation. (updated 272 days ago)
Knowledgebase Article 3,273 views tags: Drupal

Theme Plugin Wordpress Drupal Joomla Concrete5 Zen Cart Oscommerce Tomato Cart (updated 1106 days ago)
Knowledgebase Article 29,112 views tags:

A list of locations where you can find support for drupal outside of HostMonster (updated 447 days ago)
Knowledgebase Article 4,077 views tags: Drupal

How to install and activate a theme in Drupal (updated 272 days ago)
Knowledgebase Article 2,981 views tags: Drupal