I have a set of requirements for mod_rewrite that is breaking my head. Any hints / pointers would be appreciated:
domains:
www.domain-europe.com
www.domain.com
- requests for www.domain-europe.com should be redirected to www.domain.com/europe
- requests for www.domain-europe.com/someurl should be redirected to www.domain.com/someurl
- any other request coming to the server that is not www.domain-europe.com or www.domain.com should be set to www.domain.com
I can make any 1 and 3 or 2 and 3 of these work, but not all three at the same time.
Here is one of the many iterations I have tried:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.domain-europe\.com$ [NC]
RewriteRule (.*) http://www.domain.com/europe [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.domain-europe\.com/ [NC]
RewriteRule (.*) http://www.domain.com$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://www.domain.com/$1 [L,R]