How To Host Primary Domain From A Subfolder htaccess | Bluehost Support
Support
  1. bluehost knowledge base

How To Host Primary Domain From A Subfolder htaccess

Your main domain will use the public_html directory for all of its Web site files by default. Addon domains use subdirectories 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.

Joomla, Drupal, and WordPress

If you are using Joomla, Drupal, or WordPress it is recommended that you not follow these instructions, rather that you follow the instructions provided in the official documentation. Please see the links below for instructions specific to the CMS you are using.

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 your Bluehost control panel.
  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 the subdirectory to the folder where you want your site.

# Bluehost.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.

If you need further assistance, feel free to contact us via Chat or Phone:

  • Chat Support - While on our website, you should see a CHAT bubble in the bottom right-hand corner of the page. Click anywhere on the bubble to begin a chat session.
  • Phone Support -
    • US: 888-401-4678
    • International: +1 801-765-9400

You may also refer to our Knowledge Base articles to help answer common questions and guide you through various setup, configuration, and troubleshooting steps.