Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache2 rewrite with query string escaped twice

Using this rule in a virtual host configuration file leads to double escaping of the query 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 the "%25" escaping the "%" sign. Why is this happening ?

like image 446
Anna B Avatar asked Jun 07 '11 16:06

Anna B


1 Answers

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.

like image 55
regilero Avatar answered Nov 15 '22 20:11

regilero