2016-11-23 15 views
0

我有一箇舊的網站使用URL A和Bhtaccess的重定向舊子文件夾以非子

A. www.site.com/about 
B. www.site.com/about/subpage 

我需要重定向

A. www.site.com/about-us 
B. www.site.com/not-a-sub-anymore 

我的htaccess包含

Redirect 301 /about /about-us 
Redirect 301 /about/subpage /not-a-sub-anymore 

第一重定向工作正常,但是,我的第二次重定向似乎繼承了第一條規則,導致我重定向到www.site.com/about-us/not-a-sub-anymore明顯會導致404。我該如何解決這個問題?

編輯:我使用apache2.2.3,我看到了Apache 2.4.8,他們已經增加了一個RewriteRule IgnoreInherit這似乎喜歡的事,我會尋找。不幸的是,我無法控制我的Apache版本。

回答

1

我會建議通過重寫規則重定向,以防止更多的規則從射擊:

RewriteRule ^about/subpage$  /not-a-sub-anymore [R=301,L] 
RewriteRule ^about$    /about-us   [R=301,L] 

但是,如果你堅持使用301重定向,我想嘗試重新排列順序:

Redirect 301 /about/subpage /not-a-sub-anymore 
Redirect 301 /about   /about-us 
+0

使用RewriteRule工作,謝謝! – Ronnie

相關問題