Forum Moderators: phranque
I know this can be done in http.conf but is it possible to use .htaccess & Mod_rewrite to map domain names to a directory so that you can run multiple independant sites from the same hosting account?
Is the following code along the right lines?
RewriteCond %{HTTP_HOST} ^www\.secondary-site\.co\.uk [NC]
RewriteRule (.*) /websites/secondarysite/$1 [L]
I knew I was missing something, not sure if I need the final tweak to accept the www and non-www as I thought I think im forcing the www. version
Full code
RewriteCond %{HTTP_HOST} ^primary-site\.co\.uk [NC]
RewriteRule (.*) [primary-site.co.uk...] [R=301,L]
RewriteCond %{HTTP_HOST} ^secondry-site\.co\.uk [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?additional-url\.co\.uk [NC]
RewriteRule (.*) [secondary-site.co.uk...] [R=301,L]
RewriteCond %{HTTP_HOST} ^secondary-site\.co\.uk [NC]
RewriteCond %{REQUEST_URI}!^/websites/
RewriteRule (.*) /websites/$1 [L]
Does this setup look alright?
If I try going to
[primary-site.co.uk...] it works perfectly
However, if I go to [primary-site.co.uk...]
It presents a 302 redirect to [secondary-site.co.uk...]
Can anyone point me in the right direction to find out why? Any help greatly appreciated!
Present Code:
RewriteCond %{HTTP_HOST} ^primary-site\.co\.uk [NC]
RewriteRule (.*) [primary-site.co.uk...] [R=301,L]
RewriteCond %{HTTP_HOST} ^secondry-site\.co\.uk [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?additional-url\.co\.uk [NC]
RewriteRule (.*) [secondary-site.co.uk...] [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.secondary-site\.co\.uk [NC]
RewriteCond %{REQUEST_URI}!^/websites/
RewriteRule (.*) /websites/$1 [L]