Forum Moderators: phranque
So for example www.fred.co.uk
ended up at www.another.co.uk/www_fred.htm
This was done using a .htaccess file in site1 (where unrecognised domains end up), as follows:
RewriteEngine On
# Check it's not the main domain ( example.com )
RewriteCond %{HTTP_HOST}!^(www\.)?example\.com$ [NC]
# Extract the domain name without the www. part
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.co.uk$ [NC]
# Test to avoid internal loops
RewriteCond %{QUERY_STRING}!^dom=.+$ [NC]
# Goto test domain
RewriteRule .* [another.co.uk...] [R=permanent,L]
I know that I had to do something else to get it working, but can't remember what. It's also possible that the above wasn't the final version.
Any ideas. Please.
I'd suggest:
RewriteEngine on
# Check it's not the main domain ( example.com )
RewriteCond %{HTTP_HOST} !^(www\.)?example\.com [NC]
# Test to avoid internal loops
RewriteCond %{HTTP_HOST} !^www\.another\.co\.uk [NC]
# Extract the domain name without the www part
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.co\.uk [NC]
# Goto test domain
RewriteRule .* http://www.another.co.uk/www_%2.htm [R=permanent,L]
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.co\.uk(:[0-9]{1,5})?$ [NC]
Having done some tests it seems that by the time the .htaccess file in the default domain (site1) is accessed, the {HTTP_HOST} has already been re-written to that domain name. So the requested domain doesn't seem to be available.
That doesn't sound right. Any ideas.