原始请求地址:
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