![](/img/trans.png)
[英].htaccess removing *.php throws away the parameters of a URL that is passed as a GET parameter
[英]htaccess not removing URL parameters
我想從我們所有類型為.html的URL中刪除尾隨斜杠,我正在使用以下代碼
RewriteRule (.+?)\.html.+$ http://%{HTTP_HOST}/t4/$1.html [L,R=301]
這段代碼非常接近我們的需要。 當我們嘗試重定向URL之類的代碼時,我們會遇到問題
/a.html/b.php?c=1
該URL被重定向到
/a.html?c=1
我不知道為什么會這樣。 我希望此url為/a.html,看起來保留了URL參數。 您能否為此提供幫助,甚至在重定向時刪除URL參數。
嘗試添加一個?
到規則目標的末尾:
RewriteRule (.+?)\.html.+$ http://%{HTTP_HOST}/t4/$1.html? [L,R=301]
在您的DOCUMENT_ROOT/.htaccess
文件中嘗試以下規則:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s(.+?\.html).+?[?\s]
RewriteRule ^ %1 [R=302,L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.