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:
http://forum.nginx.org/read.php?2,229436,229436#msg-229436

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

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,229436,229469#msg-229469

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
http://mdounin.ru/hg/nginx-tests/file/tip/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:
http://forum.nginx.org/read.php?2,229436,229684#msg-229684

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs