htaccess Redirect to Child Directory
I'm trying to 301 redirect to a ch开发者_StackOverflow社区ild directory using .htaccess i.e.
Redirect 301 /parent http://example.com/parent/child/
Unfortunately this results in a redirect loop i.e.
/parent/child/child/child/child/etc.
Please could anyone point me in the right direction?
Redirect directive will match and redirect everything that starts with /parent
. You need to use RedirectMatch to only redirect this specific folder:
RedirectMatch 301 ^/parent/?$ http://example.com/parent/child/
The same, but using mod_rewrite:
RewriteRule ^parent/?$ http://example.com/parent/child/ [R=301,L]
NOTES: Place it in .htaccess in website root folder. If placed elsewhere some small tweaking may be required.
精彩评论