0

We have a site where multiple domain names are being condensed and 301 redirected to a single new domain name. I am testing all of our 301 redirects and am having problems with instances where the page name is identical but the domain name is different. For example:

# EXAMPLEA.COM
RewriteCond %{HTTP_HOST} ^(www\.)?examplea\.com$ [NC]
RewriteRule ^default.aspx$ http://newdomain.com/new-page-a/$1 [R=301,L]

# EXAMPLEB.COM
RewriteCond %{HTTP_HOST} ^(www\.)?exampleb\.com$ [NC]
RewriteRule ^default.aspx$ http://newdomain.com/new-page-b/$1 [R=301,L]

Currently, whichever domain comes first in my .htaccess file is the one that wins. This makes no sense to me because I have conditions in there for HTTP_HOST. Why would http://exampleb.com/default.aspx qualify for the first rewrite rule?

MrWhite
  • 43,179
  • 8
  • 60
  • 84
Adam Walter
  • 93
  • 1
  • 1
  • 10
  • 2
    Request for `exampleb.com` won't be impacted by 1st rule. Clear your browser cache and make sure you don't have any other conflicting rule. – anubhava Oct 19 '15 at 16:37
  • Does `examplea.com/default.aspx` and `exampleb.com/default.aspx` return different content? – MrWhite Oct 19 '15 at 16:53
  • Never test with `301` enabled, see this answer [Tips for debugging .htaccess rewrite rules](http://stackoverflow.com/a/9204355/1741542) for details. – Olaf Dietsche Oct 19 '15 at 22:56
  • @w3d: Yes. I'm going to chalk my problems up to a combination of things unique to my site and the server. Clearly my example is fine. – Adam Walter Oct 20 '15 at 14:57
  • @olaf-dietsche: Thank you! The tip about using 302 is a huge help. Always fighting browser caches. – Adam Walter Oct 20 '15 at 14:57

0 Answers0