首页  >  问答  >  正文

apache - url 地址重写 如何去区分 ‘?’ 问号

地址:http://localhost/aaa/bbb-ccc=222

RewriteRule ^([a-z,/,_,0-9]*)-(.*)$ index.php?routeeee=$1&$2 [L]

当用 ‘-’ 去区分地址URL时 数据都可以获取到,’-‘相当于一个分隔符

Array ( [routeeee] => aaa/bbb [ccc] =>222 )

当url地址中的‘-‘ 换成’?‘ 时就无法获取数据 RewriteRule ^([a-z,/,_,0-9]*)?(.*)$ index.php?routeeee=$1&$2 [L] http://localhost/aaa/bbb?ccc=222

Array ( [routeeee] => index [_php] => )

RewriteRule ^([a-z,/,_,0-9]*)?(.*)$ index.php?routeeee=$1&$2 [L] 这条规则该如何写 才能正常匹配 获取到正确的数据。

? 转义 ‘?’问号的话 就不匹配了

不胜感激

但是在nginx中这样是可以使用的

rewrite ^/(.)?(.)$ /index.php?route=$1&$2 last;这条规则在 nginx 是正常的。

ringa_leeringa_lee2713 天前493

全部回复(1)我来回复

  • 淡淡烟草味

    淡淡烟草味2017-05-16 17:06:10

    apache 默认是忽视 querystring 的
    RewriteRule ^([a-z,/,_,0-9]*)$ index.php?route=$1& [L,QSA]

    这样就OK了,强行执行时加上querystirng 好简单呀

    回复
    0
  • 取消回复