2

I would like to redirect a parent folder to a different place than it's subfolders. When I use the code below /cat1/page_title redirects to /new-cat-1/page_title, instead of /new-global-cat/page-title.

Redirect 301 /cat1 /new-cat-1
Redirect 301 /cat1/page_title /new-global-cat/page-title
Redirect 301 /cat2 /new-cat-2
Redirect 301 /cat2/page_title /new-global-cat/page-title

It appears the redirect for the parent folder is taking precedence over the redirect for the subfolder. I have a long list of redirects under cat1 and cat2 that I need to redirect.

How can I have a redirect that works for both the parent and the sub folders without them interfering with each other?

Additional info: This is for a Wordpress website.

Mark Rummel
  • 2,920
  • 10
  • 37
  • 52

1 Answers1

2

To fix this problem it is better to use RedirectMatch here for its regex capabilities:

RedirectMatch 301 ^/cat1/?$ /new-cat-1
RedirectMatch 301 ^/cat1/page_title/?$ /new-global-cat/page-title
RedirectMatch 301 ^/cat2/?$ /new-cat-2
RedirectMatch 301 ^/cat2/page_title/?$ /new-global-cat/page-title
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • Thanks! This was exactly what I needed! After using `RedirectMatch 301` for `/cat1/` and `/cat2/`, I was able to just keep `Redirect 301` for `/cat1/page_title/` and `/cat2/page_title/`. – Mark Rummel Oct 09 '14 at 03:46