Apache2 rewrites query string escaped twice

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

RewriteEngine 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 that "% 25" is out of the% sign. Why is this happening?

+7
query-string apache mod-rewrite
Jun 07 2018-11-11T00:
source share
1 answer

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

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

This is because & u ? , and some others are escaped by default during the rewriting process.

+14
Jun 07 2018-11-17T00:
source share



All Articles