Forum Moderators: phranque

Message Too Old, No Replies

Need a 301 re-direct for multiple pages

         

BWoodward

5:41 pm on Mar 1, 2010 (gmt 0)

10+ Year Member



Hi there. We had an issue with some links and now have incorrect/incomplete pages in google.

For example a correct url is:
http://www.example.com/nike

The incorrect urls are:
http://www.example.com/reebok/nike
http://www.example.com/addidas/nike

How can I re-direct all the pages that have the extra/wrong brand field to the correct url with just one brand with-out messing with the secondary pages?

E.g. Secondary pages
http://www.example.com/nike/nike-shoes
http://www.example.com/nike/nike-shoes/2009-season-trainers

[edited by: jdMorgan at 5:45 pm (utc) on Mar 1, 2010]
[edit reason] Please use example.com only. [/edit]

jdMorgan

5:51 pm on Mar 1, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just use a regular-expressions pattern that is end-anchored, and so will not match if there is anything following "nike":

^([^/]+)/nike$

Then back-reference the initial URL-path-part (the "correct" part of the URL-path matched by the sub-pattern in parentheses) as $1 in the substitution URL to "copy it" into the new URL.

See the concise regular expressions tutorial cited in our Apache forum charter for more info.

Jim