2016-02-25 22 views
0

我想將不存在的整個文件夾重定向到主頁。htaccess重定向一個不再存在的文件夾

我嘗試:

RedirectMatch 301 ^/folder_thats_no_longer_exists/$/
RedirectMatch 301 ^/folder_thats_no_longer_exists/
RedirectMatch 301 /folder_thats_no_longer_exists/

但這種解決方案不起作用:

事實上,這種嘗試後,該網址仍是:http://www.example.com/folder_thats_no_longer_exists/page.htm但隨着網頁的內容(這是導致顯示錯誤)。

我只是想: http://www.example.com/folder_thats_no_longer_exists/page.htm去到http://www.example.com/ 301重定向。

謝謝!

回答

0

您可以在網站根目錄的.htaccess的頂部使用這樣的規則:

RedirectMatch 301 ^/folder_thats_no_longer_exists(/.*)?$/

記住要測試這種變化之前徹底清除瀏覽器緩存。

相關問題