Reputation: 1484
I'm hosting 2 sites on the same server with different domains. I'd like to set up a redirect for a specific page on domain 1 and have it go to another external url. Have searched and searched and experimented but can't get it work.
The nearest I've got is
RewriteRule ^oldpagename$ http://externalsite/page [R=301,L]
but the problem with this is that it catches that url on the other domain as well. How can I restrict it to a specific domain?
thanks
Upvotes: 1
Views: 4550
Reputation: 143966
You need to add a condition to match against the variable `%{HTTP_HOST}:
RewriteCond %{HTTP_HOST} ^(www\.)?domain1.com$ [NC]
RewriteRule ^oldpagename$ http://externalsite/page [R=301,L]
Upvotes: 4