nginx重写URL解码URI中的第一个编码字符



我有如下规则:

location /trk/ {
    if ($args ~ "url=(.*)" ) {
        set $url $1;
        rewrite click.gif$ $url? redirect;
        rewrite redirect.gif$ $url? redirect;
    }
}

问题是如果我有这样的请求:

http://bar.com/trk/click.gif?some_foo&url=http://foo.com/%3Fmore_foo%3F

它被重写为

http://foo.com/?more_foo%3F

我需要第一个%3F不被解码为?

它似乎解码了它找到的第一个编码字符

,并且仅解码了它找到的第一个编码字符。

我正在使用 nginx 版本 1.1.13

我已经通过使用以下内容重写上述内容来解决此问题:

location /trk/click.gif { 
    if ($args ~ "url=(.*)" ) { 
        return 302 $1; 
    } 
    empty_gif; expires 0; add_header Cache-Control "no-cache, no-store, must-revalidate"; 
}

最新更新