0
我正在使用mod_rewrite提供漂亮的URL的cms。基本用例只是需要任何路径,并重写个人GET参数,就像这样:使用mod_rewrite添加基于GET的搜索参数到url
RewriteRule ^([\w-]+)[/]?$ index.php?p1=$1 [L]
RewriteRule ^([\w-]+)/([\w-]+)[/]?$ index.php?p1=$1&p2=$2 [L]
RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)[/]?$ index.php?p1=$1&p2=$2&p3=$3 [L]
RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)/([\w-]+)[/]?$ index.php?p1=$1&p2=$2&p3=$3&p4=$4 [L]
RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)/([\w-]+)/([\w-]+)[/]?$ index.php?p1=$1&p2=$2&p3=$3&p4=$4&p5=$5 [L]
我也有发送GET请求搜索形式,但我不知道如何将它添加到重写规则。例如:
http://site.domain/search?query=abc
应改写为:
http://site.domain/index.php?p1=search&query=abc
我曾尝试以下,有一些变化,但作为expexted搜索参数不会出现在$ _GET:
RewriteRule ^search?(.+)[/]?$ index.php?p1=search$1[L]
谢谢,这工作像一个魅力! – cornergraf
不客气,很高兴它解决了。 – Croises