开发者

Apache2 rewrite with query string escaped twice

开发者 https://www.devze.com 2023-03-11 20:05 出处:网络
Using this rule in a virtual host configuration file leads to double escaping of the query parameters:

Using this rule in a virtual host configuration file leads to double escaping of the query parameters:

RewriteE开发者_开发百科ngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

For example:

http://example.com?f=hello%20world

Leads to

https://example.com?f=hello%2520world

Note the "%25" escaping the "%" sign. Why is this happening ?


Try to add the [NE] (noescape) tag at the end of the rewrite rule:

RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [NE]

This happens because & and ? and some others are escaped by default in the rewrite process.

0

精彩评论

暂无评论...
验证码 换一张
取 消