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

原始请求地址:

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

重写的请求地址:

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

这是我自己的配置:

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

你看到我的问题了吗?重写的地址会自动添加,但这不是我想要的.相同的参数键将导致后盖正面.
最佳答案
为了防止将原始查询字符串附加到目标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

dawei

【声明】:唐山站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。