How to make a subfolder the main folder for your BlueHost primary domain

If you are using BlueHost for your web hosting you already know that the domain you use to signup for your account is your Primary domain. By default, the Primary domain is set to reside in the public_html

I recently moved my hosting to BlueHost and have been very happy with both the tech support and their services.  BlueHost allows you to host multiple domains within the one account. The main or primary domain on the hosting account uses the public_html folder for all of its web site files. Any addon domains use subfolders inside the public_html folder. When your viewer types in the url or clicks on a link to the url, that viewer is directed to the domain and sees the url in the address bar. No problem so far.

I use Expression Web as my web editor and publish using the ftp facility from within the program in most cases. I had been using Filezilla to publish to the main domain frontpage-to-expression.com as there are two of us who maintain the site. Imagine my surprise the first time I used the ftp client from within Expression Web to have the program compare the domain I was publishing to ALL the folders for every domain within the public_html directory.

There had to be a way to remedy this so I went searching the BlueHost support forums and found it. If you are hosting your domains on BlueHost and do NOT want all of the files for your main domain within the public_html directory as well as all of the addon domain folders you can follow the  How to host the Primary Domain from a subfolder (.htaccess) from the BlueHost knowledge base or continue with this tutorial below.

Visitors to your Web site will not be able to tell that your main domain is using a subfolder, they will still see the Web site address as http://www.your-domain.com/page.html BUT for SEO purposes I want my visitors to see http://www.your-domain.com/ so I made some changes in the code BlueHost gives  for achieving this. You can see the results by visiting http://www.frontpage-to-expression.com

Creating the .htaccess file

This is the information provided by BlueHost:

# Bluehost.com
# .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 your-domain.com to be your main domain.

RewriteCond %{HTTP_HOST} ^(www.)?your-main-domain.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.  NOTE: I do NOT want to be redirected to a specific file name so modified the code here.

RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$ RewriteRule ^(/)?$ subfolder/index.php [L]

My final code looks like this:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?frontpage-to-expression.com$
RewriteCond %{REQUEST_URI} !^/frontpage-to-expression/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /frontpage-to-expression/$1
RewriteCond %{HTTP_HOST} ^(www.)?frontpage-to-expression.com$
RewriteRule ^(/)?$ frontpage-to-expression/ [L]

If you wish, you may download the sample-htaccess.txt file and edit for YOUR domain.

  • Open the above file in Notepad View Screenshot
  • From the menu, select: File > Save As
  • A dialogue box will open. At the top of the box make sure it has the folder where your website is located next to the Save in area.
  • To the right of File name type in .htaccess
  • To the right of Save as type, select All Files View Screenshot
  •  Click the save button.

Uploading the .htaccess file

Once edited, you will need to upload the .htaccess file using your ftp program. You should have received a welcome email from BlueHost with your temporary information that will look something like this:

Temporary Web Address:
http://22.333.444.555/~username/
Temporary FTP Address:
ftp://username@22.333.444.555/public_html

Before you can upload the file you will need to set up your ftp program with the correct settings. Among the various free FTP programs available to download on the internet is FileZilla which I use and highly recommend. It can be downloaded free of charge from http://www.filezilla-project.org. You can access a detailed tutorial from BlueHost Support on Getting Started Wizard :: FileZilla FTP

  • Publish the .htaccess to the public_html directory.
  • Create a new folder within the public_html directory with the same name you used for the folder when creating the .htaccess file i.e. your-domain.com now points to the folder your-domain

I also add an .htaccess file to the new folder you just created that will redirect the non www version of the domain to the www version of the domain. See  Google Canonical problems - www versus non.www..

Now you have your public_html root directory that contains the newly created .htaccess file and subfolders for each of your domains not just your addon domains.

View Screenshot.View Screenshot

Download BlueHost Tutorials EBook.Now that you have created your new main domain directory and uploaded your .htaccess file, you are ready to publish to the newly created directory. Additional files created by BlueHost when the main domain is setup can also be moved to the newly created directory. They are various error pages - 400.shtml, 404.shtml, etc. These pages can be edited through your Control Panel OR your web editor.

All of the BlueHost Tutorials have been assembled into one EBook in pdf format for easy printing. The file has been zipped for quicker downloading.