Give Primary Domain a folder for Hostgator Server (Change Main Domain root Directory)

It’s been a while since my last article. Was busy moving sites to Hostgator.

In this article I will explain how to give primary domain a folder for Hostgator Server. In simple words, we will change the primary domain folder from root to another folder of our choice. This will work with most of the hosting companies.

This will help us to have a clean root folder in the server.

All you have to do is copy paste the following line to your. htaccess file.

RewriteEngine on
RewriteBase /
RewriteRule ^(.*)$ /[highlight]yourfoldername[/highlight]/$1

Change [highlight]yourfoldername[/highlight] to the name of the folder where you want to forward your primary domain.

If you get a 500 error or any other server error, remove all the lines from your. htaccess and just use the above code. Keep a backup of the. htaccess before deleting the lines.

badge