Stefan
Stefan

Reputation: 9264

301 redirect conflicts with other 301 redirects

I ran into a redirect conflict and don't get it solved. For example, I have following redirects:

redirect 301 http://www.example.com/mobile-cars http://www.example.com/cars/
redirect 301 http://www.example.com/mobile-cars/for-her http://www.example.com/cars-for-her/
redirect 301 http://www.example.com/mobile-cars/for-him http://www.example.com/cars-for-him/
redirect 301 /mobile-cars/for-her/kia-moto http://www.example.com/kia-12.html

The first redirect is conflicting with the all others (I assume its because the first one is always part of the other domains). Even if I get rid of http://www.example.com/ and just try to redirect the queries it doesn't work.

Is there any parameter which prevents using a redirect for following redirects or something else?

Thank you so much for help.

Upvotes: 1

Views: 258

Answers (1)

anubhava
anubhava

Reputation: 785581

You need to keep specific redirects before the generic catch-all ones:

redirect 301 /mobile-cars/for-her/kia-moto /kia-12.html
redirect 301 /mobile-cars/for-her /cars-for-her/
redirect 301 /mobile-cars/for-him /cars-for-him/
redirect 301 /mobile-cars /cars/

OR using RedirectMatch:

RedirectMatch 301 ^/mobile-cars/for-her/kia-moto /kia-12.html
RedirectMatch 301 ^/mobile-cars/(for-her|for-him) /cars-$1/
RedirectMatch 301 ^/mobile-cars /cars/

Upvotes: 1

Related Questions