799718014 发表于 2017-1-19 15:13:35

军哥,nginx伪静态参数超过九个的规则要怎么写?

军哥,你好。nginx伪静态参数超过九个的规则要怎么写?现在我们的网站url上是可以显示超过9个参数的。但是我php后台接收不了第九个参数后的参数的值。我按百度上的教程配置了,但是php还是接收不了值,希望军哥有空指导一下,谢谢。

例如:http://zb.16rd.com/tasklist-p-19-hd_tag_tech_id-115-hd_indus_id-318-hd_tag_id-105.html这里九个参数 参数的值正常获取
例如:http://zb.16rd.com/tasklist-hd_indus_id-318-hd_tag_id-105-hd_tag_tech_id-115-p-19-o-7.html 这里十一个参数 ,第十一参数的值获取不了了;

伪静态规则:
location = /index.html {      

   if ( $host ~ 'zb.16rdtext.com' ){
                rewrite ^/index.html$ /index.php;
                rewrite ^/(\w+).html$ /index.php?do=$1;
                rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*).html$ /index.php?do=$1&$2=$3;
                rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*).html$ /index.php?do=$1&$2=$3&$4=$5;
                rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*).html$ /index.php?do=$1&$2=$3&$4=$5&$6=$7;
                rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*).html$ /index.php?do=$1&$2=$3&$4=$5&$6=$7&$8=$9;


rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(?'n0'\w+)-(?'n1'[^\-\#\%\?\&]*).html$ index.php?do=$1&$2=$3&$4=$5&$6=$7&$8=$9&$n0=$n1

rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(?'n0'\w+)-(?'n1'[^\-\#\%\?\&]*)-(?'n2'\w+)-(?'n3'[^\-\#\%\?\&]*).html$ index.php?do=$1&$2=$3&$4=$5&$6=$7&$8=$9&$n0=$n1&$n2=$n3

rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(?'n0'\w+)-(?'n1'[^\-\#\%\?\&]*)-(?'n2'\w+)-(?'n3'[^\-\#\%\?\&]*)-(?'n4'\w+)-(?'n5'[^\-\#\%\?\&]*).html$ index.php?do=$1&$2=$3&$4=$5&$6=$7&$8=$9&$n0=$n1&$n2=$n3&$n4=$n5

rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(?'n0'\w+)-(?'n1'[^\-\#\%\?\&]*)-(?'n2'\w+)-(?'n3'[^\-\#\%\?\&]*)-(?'n4'\w+)-(?'n5'[^\-\#\%\?\&]*)-(?'n6'\w+)-(?'n7'[^\-\#\%\?\&]*).html$ index.php?do=$1&$2=$3&$4=$5&$6=$7&$8=$9&$n0=$n1&$n2=$n3&$n4=$n5&$n6=$n7
      }
}

licess 发表于 2017-1-19 15:57:23

不大清楚,可以咨询一下你程序的开发方

799718014 发表于 2017-1-19 17:22:39

:L我就是程序员,好尴尬,我百度有说超过九个参数的要用重命名的方式

799718014 发表于 2017-2-6 11:49:25

伪静态参数超过九个的问题

方法参考地址:
https://zhidao.baidu.com/question/937097964159925972.html?qbl=relate_question_0&word=nginx%CE%B1%BE%B2%CC%AC%B2%CE%CA%FD
分组捕获的规则:
如果伪静态参数超过九个,伪静态重写规则的要点是:左右两边都要有变量,
#################################贴图占位##################

.htaccess文件的完整内容:
location /{
      if ( $host ~ 'zb.16rdtext.com' ){
                rewrite ^/index.html$ /index.php;
                rewrite ^/(\w+).html$ /index.php?do=$1;
                rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*).html$ /index.php?do=$1&$2=$3;
                rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*).html$ /index.php?do=$1&$2=$3&$4=$5;
                rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*).html$ /index.php?do=$1&$2=$3&$4=$5&$6=$7;
                rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*).html$ /index.php?do=$1&$2=$3&$4=$5&$6=$7&$8=$9;
                rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(?\w+)-(?'n1'[^\-\#\%\?\&]*).html$ /index.php?do=$1&$2=$3&$4=$5&$6=$7&$8=$9&$n0=$n1;
                rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(?\w+)-(?'n1'[^\-\#\%\?\&]*)-(?'n2'[^\-\#\%\?\&]*)-(?'n3'[^\-\#\%\?\&]*).html$ /index.php?do=$1&$2=$3&$4=$5&$6=$7&$8=$9&$n0=$n1&$n2=$n3;
                rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(?\w+)-(?'n1'[^\-\#\%\?\&]*)-(?'n2'[^\-\#\%\?\&]*)-(?'n3'[^\-\#\%\?\&]*)-(?'n4'[^\-\#\%\?\&]*)-(?'n5'[^\-\#\%\?\&]*).html$ /index.php?do=$1&$2=$3&$4=$5&$6=$7&$8=$9&$n0=$n1&$n2=$n3&$n4=$n5;
                rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(?\w+)-(?'n1'[^\-\#\%\?\&]*)-(?'n2'[^\-\#\%\?\&]*)-(?'n3'[^\-\#\%\?\&]*)-(?'n4'[^\-\#\%\?\&]*)-(?'n5'[^\-\#\%\?\&]*)-(?'n6'[^\-\#\%\?\&]*)-(?'n7'[^\-\#\%\?\&]*).html$ /index.php?do=$1&$2=$3&$4=$5&$6=$7&$8=$9&$n0=$n1&$n2=$n3&$n4=$n5&$n6=$n7;
                rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(?\w+)-(?'n1'[^\-\#\%\?\&]*)-(?'n2'[^\-\#\%\?\&]*)-(?'n3'[^\-\#\%\?\&]*)-(?'n4'[^\-\#\%\?\&]*)-(?'n5'[^\-\#\%\?\&]*)-(?'n6'[^\-\#\%\?\&]*)-(?'n7'[^\-\#\%\?\&]*)-(?'n8'[^\-\#\%\?\&]*)-(?'n9'[^\-\#\%\?\&]*).html$ /index.php?do=$1&$2=$3&$4=$5&$6=$7&$8=$9&$n0=$n1&$n2=$n3&$n4=$n5&$n6=$n7&$n8=$n9;
      }
}


location = /index.html {
      if ( $host ~ 'zb.16rdtext.com' ){
               rewrite ^(.*)$ /index.php;
      }
}
页: [1]
查看完整版本: 军哥,nginx伪静态参数超过九个的规则要怎么写?