views:

21

answers:

1

I've read over the similar questions on stackoverflow, but have been unable to get this working. I keep getting stuck in an infinite loop.

I'm trying to redirect a specific url to a child of that url. eg:

Redirect 301 /category/parent-cat http://domain.com/category/parent_cat/child_cat

A: 

Sticking with mod_alias, you could use RedirectMatch instead so that you could anchor the pattern at the end of the URL:

RedirectMatch 301 ^/([^/]+/[^/]+)/?$ http://example.com/$1/child_cat

The mod_rewrite solution is almost identical:

RewriteEngine on

RewriteCond ^([^/]+/[^/]+)/?$ http://example.com/$1/child_cat [R=301,L]

You could naturally replace the [^/]+ patterns with the specific paths you were looking for, as well. I thought I'd provide a more general solution just in case, though.

Tim Stone
Thanks Tim. I had troubles with the Rewrite, but the Redirect works great. Thanks for providing a general solution as well!
Aaron Moodie