2011-07-19 148 views
2

我想301重定向到一個子目錄使用的.htaccess即htaccess的重定向到子目錄

Redirect 301 /parent http://example.com/parent/child/ 

不幸的是這會導致重定向循環即

/parent/child/child/child/child/etc. 

請任何人都可以點我在正確的方向?

回答

2

Redirect指令將匹配並重定向以/parent開頭的所有內容。您需要使用RedirectMatch只重定向這個特定的文件夾:

RedirectMatch 301 ^/parent/?$ http://example.com/parent/child/ 

相同,但使用mod_rewrite的

RewriteRule ^parent/?$ http://example.com/parent/child/ [R=301,L] 

注: 將其放置在網站根目錄的.htaccess。如果放置在其他地方可能需要一些小的調整。

+0

很好,謝謝LazyOne。 – Sam