nginx跳转的问题
各位大虾好,小虾遇到一个需求
源网址是:
http://dvlshop.lechange.com/index.php/wap/?client_id=lc_mall_m&redirect_uri=https%3A%2F%2Fdvlshop.lechange.com%2Fopenapi%2Ftrustlogin_api%2Fparse%2Fwap_trustlogin_lecheng%2Fcallback&response_type=code&scope=read&state=http%3A%2F%2Fdvlshop.lechange.com%2Findex.php%2Fwap&user=token%2Flcid_9f9lmo2u6i7hkl6t6eaodn2blmg5jbsg&expire=1514191636&nonce=cdizHO6uvSx5JK79Kmtz5RBpSi0ROhpF&signature=VeCceYCWDE6BZjIdni/68YCmhqc=%27
现在需求如下:
- 先判断是否有client_id
- 再判断是否有response_type
- 有,去掉response_type
目标的网址是:
http://dvlshop.lechange.com/index.php/wap/?client_id=lc_mall_m&redirect_uri=https%3A%2F%2Fdvlshop.lechange.com%2Fopenapi%2Ftrustlogin_api%2Fparse%2Fwap_trustlogin_lecheng%2Fcallback&=code&scope=read&state=http%3A%2F%2Fdvlshop.lechange.com%2Findex.php%2Fwap&user=token%2Flcid_9f9lmo2u6i7hkl6t6eaodn2blmg5jbsg&expire=1514191636&nonce=cdizHO6uvSx5JK79Kmtz5RBpSi0ROhpF&signature=VeCceYCWDE6BZjIdni/68YCmhqc=%27
我把response_type 前面设定是$1,后面设定是$2。自己的写的规则如下:
location ~ ..php.
{
include php_fcgi.conf;
include pathinfo.conf;
if ( $query_string ~ "(.*)response_type(.*)" ) {
set $id $1;
set $query $2;
rewrite ^.*$ http://dvlshop.lechange.com/index.php/wap/$id$query last;
}
}
结果执行了之后,原来是 $1+response_type +$2,现在跳转成了$1 +$2 + $1 +response_type +$2,而我只是想要$1 + $2,请问应该怎么写呢?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题已经解决了,改用return 301