nginx rewrite正则子组最多匹配到$9

Posted dongruiha

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx rewrite正则子组最多匹配到$9相关的知识,希望对你有一定的参考价值。

nginx rewrite正则匹配()匹配子组最多匹配到$9,就是从$0到$9

当需要匹配更多子组时,可通过变量来实现

if ($uri ~ ^/forum-15/sortid-74/(.*?)(lastpost|dateline)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)\.html$){
    set $orderby $2;
    set $mdate $3;
    set $workhours $4;
    set $pricerange $5;
    set $page $6;

    rewrite ^([^\.]*)/forum-15/sortid-74/(\w+)/(\w+)/(.*?)/(\w+)/(\w+)/(\w+)/(lastpost|dateline)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=15&filter=sortid&sortid=74&epuipment=$2&brand=$3&model=$4&province=$5&city=$6&district=$7&mdate=$mdate&workhours=$workhours&pricerange=$pricerange&page=$page&orderby=$orderby last;
}







以上是关于nginx rewrite正则子组最多匹配到$9的主要内容,如果未能解决你的问题,请参考以下文章

Nginx正则表达式location匹配Rewrite重写详解

nginx中的rewrite语句

Nginx Rewrite规则

Nginx rewrite

Nginx学习——location和rewrite

nginx location配置和rewrite写法