I've read over the s开发者_运维百科imilar 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
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.
精彩评论