Forum Moderators: phranque

Message Too Old, No Replies

301 redirect problem

         

ChildeRoland

9:54 am on Apr 7, 2009 (gmt 0)

10+ Year Member



I'm having a problem as I need to 301 redirect an entire directory to one place, AND redirect sub-directories within it to another place.

Problem being using the basic:

redirect 301 /catcode1/ [domain.com...]

(this redirect works, but)

redirect 301 /catcode1/catcode2/ [domain.com...]

(this redirect doesn't work because it seems the first redirect is overriding it because its telling it to send EVERYTHING in /catcode1/ to the location above, and it breaks the redirect for the subcat /catecode1/catecode2/.

Any ideas on how to make the redirect for the first directory, not override the subdirectories stored within it?

jdMorgan

12:46 pm on Apr 7, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



1) Reverse the two lines, so that the more-specific redirect directive is evaluated first.
-or-
2) Use RedirectMatch, which uses regular-expressions pattern-matching instead of the simple prefix-matching used by the Redirect directive.

In both cases, be sure that the new URLs do not match either of your directives' matching-strings; If they do, then you will get redirected again and again.

See Apache mod_alias documentation for details on RedirectMatch.

Jim