/filename.php成爲/文件名 - 失敗刪除尾部斜槓和php/html擴展名。跟蹤斜槓場景無法刪除擴展
/filename.php/成爲/filename.php - 失敗!
/文件名/成爲文件名 - 成功!
我將如何刪除具有結尾斜槓的方案的擴展?
Options +MultiViews
RewriteEngine On
# remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
RewriteRule ^(.+?)/$ /$1 [R=301,L]
# remove php/html extension
RewriteCond %{THE_REQUEST} /index\.(php|html)[\s/?] [NC]
RewriteCond %{REQUEST_URI} !/system/ [NC]
RewriteRule ^(.*?)index\.(?:php|html)(.*)$ $1$2 [R=301,NE,L]
我看不出filename.php'如何'重定向到'filename'因爲你的規則檢查'* index。(php | html)*'。你究竟想在這裏完成什麼?請更具體一點,因爲你的問題說了一件事,但你的代碼說另一件事。 –
該文本是我正在努力完成的。代碼是我的嘗試。到目前爲止,我認爲我實際完成的所有工作都是刪除斜線。 –