Mod rewrite Nginx mod_rewrite$request_uri操作

Mod rewrite Nginx mod_rewrite$request_uri操作,mod-rewrite,nginx,Mod Rewrite,Nginx,我想做一些重定向,但涉及到$args 我正在努力做到以下几点: rewrite /aaa?a=1&aa=2 /bbb?b=1&bb=2 permanent; 但它不起作用。不过,下面这条线很好用 rewrite /aaa /bbb permanent; 我将这些行添加到我的配置文件中: proxy_set_header x-request_uri "$request_uri"; proxy_set_header x-args "$args";

我想做一些重定向,但涉及到$args

我正在努力做到以下几点:

rewrite /aaa?a=1&aa=2 /bbb?b=1&bb=2 permanent;
但它不起作用。不过,下面这条线很好用

rewrite /aaa /bbb permanent;
我将这些行添加到我的配置文件中:

        proxy_set_header x-request_uri "$request_uri";
        proxy_set_header x-args "$args";
我可以看到这些标题:

GET /aaa?a=1&aa=2 HTTP/1.0
Host: www.example.com
x-request_uri: /aaa?a=1&aa=2
x-args: a=1&aa=2
Connection: close
User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
Accept: */*
我做错了什么?在考虑完整的$request\u uri的情况下,有没有办法实现重定向?

我在irc.freenode.net nginx上得到了答案:

Mod_rewrite与仅带args而不带args的url不匹配,请改用if或map

如果:

响应标题:

< HTTP/1.1 301 Moved Permanently
< Server: nginx/1.0.15
< Date: Wed, 02 Jul 2014 20:05:34 GMT
< Content-Type: text/html
< Content-Length: 185
< Connection: keep-alive
< Location: http://www.example.com/bbb?b=1&bb=2
< x-uri: /aaa?a=1&aa=2
< HTTP/1.1 301 Moved Permanently
< Server: nginx/1.0.15
< Date: Wed, 02 Jul 2014 20:05:34 GMT
< Content-Type: text/html
< Content-Length: 185
< Connection: keep-alive
< Location: http://www.example.com/bbb?b=1&bb=2
< x-uri: /aaa?a=1&aa=2