0

I'm trying to find a way make rewrite rules not to interfere with each other.

RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.com
RewriteRule ^old-url.html(.*)$ /new-url-1/? [R=301,NC,L]

RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com
RewriteRule ^old-url.html(.*)$ /new-url-2/? [R=301,NC,L]

RewriteCond %{HTTP_HOST} ^(www\.)?domain3\.com
RewriteRule ^old-url.html(.*)$ /new-url-3/? [R=301,NC,L]

RewriteCond %{HTTP_HOST} ^(www\.)?domain4\.com
RewriteRule ^old-url.html(.*)$ /new-url-4/? [R=301,NC,L]

If I access, let's say www.domain4.com/old-url.html I'm redirected to www.domain4.com/new-url-1/

Any ideas? Thanks,

Aknot
  • 499
  • 1
  • 8
  • 18
  • Anyone know how to make this work? Please? – Aknot May 04 '15 at 07:56
  • 1
    Your question doesn't make sense. How should the rewrite know which of the `old-url.hmtl` request should go to which new url? They are all exactly the same in your example. – Stephan Muller May 04 '15 at 08:56
  • Thanks Stephan! That's exactly the problem, isn't there a way to first check the current domain name, for which one the redirect should be executed? In the example I have tested to use a `RewriteCond`on the current domain, but with no luck. – Aknot May 05 '15 at 09:57
  • That makes sense, and yes that should be possible. Have you tried using RewriteLog to debug this and see if the first rule even matches at all? http://stackoverflow.com/questions/9632852/how-to-debug-apache-mod-rewrite. – Stephan Muller May 05 '15 at 10:02
  • Also, what are you using `(.*)` for in the RewriteRule, and why does the destination URL contain a `?` ? – Stephan Muller May 05 '15 at 10:07

0 Answers0