我有这样的链接(未知数量的变量),我想改变:mod_rewrite正则表达式:“.../auto/bmw?year = 2014&...”to“.../auto.php?company = bmw?year = 2014&...”
http://test.my/news/auto?year=2014&thema2=design http://test.my/news/auto?year=2005&... http://test.my/news/moto?year=2012&month=10&championship=MotoGP
进入这样的:
http://test.my/news.php?thema=moto&year=2012&month=10&&championship=MotoGP http://test.my/news.php?thema=auto&year=2014&thema2=design
我试图这样做,但没有成功:
RewriteRule ^news/([a-zA-Z_.]+)\??([a-zA-Z0-9_-.]+)$ news.php?thema=$1&$2 [NC,L,QSA]
PHP vardump($ _ GET):
array(6) {
["thema"]=> string(5) "mot"
["o"]=> string(0) ""
["year"]=> string(4) "2012"
["month"]=> string(2) "10"
["championship"]=> string(6) "MotoGP" }
我认为这是一个问号,并用正则表达式的第二部分的问题。 请告诉我这是如何做得更好。谢谢。
你不必让你重写查询部分。只要你使用'[QSA]',参数就会自动传输。 – h2ooooooo