鍍金池/ 問答/Java  Linux  網(wǎng)絡(luò)安全/ nginx跳轉(zhuǎn)的問題

nginx跳轉(zhuǎn)的問題

各位大蝦好,小蝦遇到一個需求

源網(wǎng)址是:

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


現(xiàn)在需求如下:

  1. 先判斷是否有client_id
  2. 再判斷是否有response_type
  3. 有,去掉response_type

目標(biāo)的網(wǎng)址是:

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 前面設(shè)定是$1,后面設(shè)定是$2。自己的寫的規(guī)則如下:
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;
    }
}

結(jié)果執(zhí)行了之后,原來是 $1+response_type +$2,現(xiàn)在跳轉(zhuǎn)成了$1 +$2 + $1 +response_type +$2,而我只是想要$1 + $2,請問應(yīng)該怎么寫呢?

回答
編輯回答
魚梓

問題已經(jīng)解決了,改用return 301

2018年5月4日 00:47