valentin vannay

valentincognito

Change the default directory of the main domain (Bluehost)

2017-05-21

The other day I was desperately trying to change the configuration of my htaccess to host my main domain (on a shared hosting Bluehost server) from a subfolder and not the default location which is public_html/www/

If you search those keywords on google you will probably like me stumble accross Bluehost themselves trying to explain how to do it.

You can find their post here: https://my.bluehost.com/cgi/help/347

But it did not work for me at all.. I even contacted the support but I have gotten nothing from them. They just said it was my fault…
But then after some research these .htaccess lines changed my life:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/subdirectory/ 
RewriteCond %{HTTP_HOST} ^(www\.)?your-domain\.
RewriteRule ^(.*)$ /subdirectory/$1 [L]

Et voila ! Works like a charm !
I am not an htaccess rules expert so I am not 100% sure what was wrong with Bluehost’s recommended configuration. But this one works and I thought it might help someone.

Cheers