首页 > 代码库 > nginx rewrite正则子组最多匹配到$9

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