Rewrite automatically unencodes question mark

Hello,

I have this rewrite rule.

rewrite ^(.+)$ $url? permanent;

where $url is
http://example.com/ez/ciaapkznke/&subid1=1&lnkurl=http://www.someotherwebsite.com/books%3Faffid%3Dtyroo%26cmpid%3Daffiliate_promo_tyroo

However its redirected to

where $url is
http://example.com/ez/ciaapkznke/&subid1=1&lnkurl=http://www.someotherwebsite.com/books?affid%3Dtyroo%26cmpid%3Daffiliate_promo_tyroo

%3F got changed to ? which i dont intend to…

Any help?

Posted at Nginx Forum:

It seems only the first %3F gets un-encoded. Remaining %3F remains as it
is… Could it be a bug?

Posted at Nginx Forum:

Hello!

On Wed, Aug 08, 2012 at 01:12:46PM -0400, jimishjoban wrote:

It seems only the first %3F gets un-encoded. Remaining %3F remains as it
is… Could it be a bug?

More or less yes, it’s weird historic behaviour which should be
eventually fixed (and we even have several TODO test cases
for this, see
nginx-tests: 032ccd3118cb rewrite_unescape.t).

For now I would recommend using

return 301 $uri;

which doesn’t try to do any unescaping.

Maxim D.

Thanks!

that works but would it be possible to execute something else in
background
after doing a return?

So I need to execute something which does the redirect and then inserts
some
logs in the database… But only after redirect, so its a bit faster…

Posted at Nginx Forum: