.htaccess alias setup
I’ve got this situation:
I own 4 domains, they all point to the same hosting space. So, each domain would load exactly the same pages. I.e, example1.com/home/ is exactly the same as example2.com/home/
I’ve searched forever to find a .htaccess script to do this, and I finally have it.
Here is the magic code (replace example1.com with yourdomain and example1/ with your directory for that domain):
RewriteEngine on
RewriteOptions MaxRedirects=1
#Website 1
RewriteCond %{HTTP_HOST} ^(www.)?example1.com$
RewriteCond %{REQUEST_URI} !^/example1/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /example1/$1
RewriteCond %{HTTP_HOST} ^(www.)?example1.com$
RewriteRule ^(/)?$ example1/ [L]
The above forwards any requests for example1.com (or www.example1.com) and silently loads the directory “example1/”.
I.e, the address www.example1.com/test/ will actually load up www.example1.com/example1/test
But, the address in the address bar will not change.
For multiple domains, copy the code from the “Website 1″ comment downwards.
No Comments »
RSS feed for comments on this post. TrackBack URL