2017-02-24 69 views
1

我已經重定向目錄410 .htaccess重定向文章從目錄301重定向到410

​​

現在我想寫一個規則的一些文章從/書籍/視頻/重定向到301頁。我試圖如下

RewriteRule ^(.*)/books/videos/how-to-find-videos.html /books/how-to-find-videos.html [L,R=301] 

當我訪問www.mysite.com/books/videos/how-to-find-videos.html它顯示我410頁離開。這意味着301規則不適用於此。我如何爲同一個目錄創建410 and 301

在此先感謝。

回答

1

不要混合來自不同Apache模塊的RedirectRewriteRule指令。

有像這樣在給定的順序:

RewriteEngine On 

# specific files are redirected with 301 
RewriteRule ^/?books/videos/how-to-find-videos\.html$ /books/how-to-find-videos.html [L,R=301,NC] 

# remaining URIs from this path to get 410 
RewriteRule ^/?books/videos/ - [L,R=410] 

確保測試此之前,清除瀏覽器緩存。

+1

感謝@anubhahva它爲我工作。 – Hemantwagh07