Redirector - unescaping query parameters

Chris West lists at
Tue Feb 1 19:27:45 MSK 2011

I am trying to use nginx as a redirector that logs some data about the
request and then redirects the user to a user-specified URL.

This works well unless the user-specified URL contains query parameters.

For example, if this URL is requested:

I use this rewrite rule to redirect:

if ($arg_r ~* http.*) {
  rewrite ^(.*)$ $arg_r? redirect;

Any parameters in the user-specified URL are pre-escaped - notice that
the colon was replaced with %3A.

However, if the 'r' parameter that I redirect to also contains escaped
parameters, they do NOT get unescaped. For example, if the user requests
this URL:

That is incorrectly rewritten as:

How can I instead redirect the user to:

I do not know what parameters the user will be supplying in the
user-specified URL beforehand, so I can not extract them and rewrite
them manually. That is why they are encoded inside the 'r' parameter.

Posted via

More information about the nginx mailing list