在虚拟主机configuration文件中使用此规则会导致查询参数双重转义:
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
例如:
http://example.com?f=hello%20world
导致
https://example.com?f=hello%2520world
请注意转义“%”符号的“%25”。 为什么发生这种情况?
尝试在重写规则的末尾添加[NE] (noescape)标签:
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [NE]
发生这种情况是因为&
和?
还有一些在重写过程中被默认转义。