此重写代码正在更改意外的特殊字符

This rewriting code is changing special characters which is unexpected

此代码用于通过 .htaccess 从 URL 中删除空参数:

    RewriteCond %{QUERY_STRING} ^(.+?&)?[^=]+=(?:&(.*))?$
    RewriteRule ^ %{REQUEST_URI}?%1%2 [R=302,L]

它删除了空 URLS 但问题是它正在更改 URL 中的特殊字符,这导致了很多错误。例如: 山西省 更改为:%252525E5%252525B1%252525B1%252525E8%252525A5%252525BF%252525E7%2525259C%2525258‌​1

尝试在您的规则中使用 NE 标志。

RewriteCond %{QUERY_STRING} ^(.+?&)?[^=]+=(?:&(.*))?$
RewriteRule ^ %{REQUEST_URI}?%1%2 [R=302,NE,L]

http://httpd.apache.org/docs/current/rewrite/flags.html#flag_ne