发表于 2018-11-14 10:44:42

nginx rewrite小记以及break,last区别

  需求:访问http://192.168.1.222:8099/ksdkfd/callback   其中ksdkfd是任意字符
  跳转到http://192.168.1.222:8099/api/paycb/ksdkfd
  location ~* ^/.+/callback$ {
  indexindex.html index.htm;
  rewrite "^/(.+)/callback" "/api/paycb/$1" permanent;
  }
  break 和last的区别
  location /break {
  rewrite /break/(.*) /test/$1 break;
  echo break page;
  }
  location /last {
  rewrite /last/(.*) /test/$1 last;
  echo last page;
  }
  location /test/ {
  echo test page;
  }
  匹配到break之后,rewrite完成了。继续执行下面的。
  匹配到last之后,rewrite完成了。跳出location,重新匹配rewrite之后的url,也就是匹配到了/test/ ;
  注意,要使用echo需要安装nginx的echo模块。

页: [1]
查看完整版本: nginx rewrite小记以及break,last区别