Nginx重写地址不会自动添加参数

原始请求地址:

www.example.com/index.php?r=mobile/receive/index 

重写的请求地址:

 www.example2.com/newindex.php?r=mobile2/receive2/index2 

这是我自己的configuration:

 if ($args ~* "^r=mobile/receive/index") { rewrite ^ "http://www.example2.com/newindex.php?r=mobile2/receive2/index2"; } 

但重写地址的结尾是这样的:

 http://www.example2.com/index.php?r=mobile2/receive2/index2&r=mobile/receive/index 

你看到我的问题吗? 重写的地址是自动添加的,但这不是我想要的。 相同的参数键将导致后盖正面。

为了防止将原始查询string附加到目标URL,您需要在重写的URL末尾添加一个附加问号( ? )。 例如:

 rewrite ^ http://www.example2.com/newindex.php?r=mobile2/receive2/index2?; 

参考:
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite