[英]Apache mod_rewrite: remove only a specific folder from the url and remove the extension from all the files inside that folder
我嘗試了一些在Web上的.htaccess文件(位於網站根目錄中)上找到的其他解決方案,但最終總是遇到“內部服務器錯誤” ...
我需要一條通用規則,以從URL及其包含的所有文件的擴展名中刪除特定文件夾(在末尾添加斜杠),並重定向到重寫的url。 因此,例如:
我要處理的文件夾稱為“頁面”,因此該規則不應影響任何其他文件夾,並且我希望該網址
http://www.example.com/subfolder/pages/
will be rewrited/redirected to
http://www.example.com/subfolder/
和
http://www.example.com/subfolder/pages/page1.php
will be rewrited/redirected to
http://www.example.com/subfolder/page1/
和
http://www.example.com/subfolder/pages/subpages/page1.php
will be rewrited/redirected to
http://www.example.com/subfolder/subpages/page1/
等等...
我該如何實現?
在以下兩個規則中,這更合乎邏輯:
沒有測試規則,但這應該可以幫助您。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.