我对rewriterule很新,我试图重写如下
index.php?controller=Listings&action=newview&id=3
RewriteRule ^/?news/?(.*)$ /index.php?controller=Listings&action=news&$1&%{QUERY_STRING} [L]
当我在网址上调用“/ newview / id / 3”时它没有用,谢谢你提前获取任何建议。
答案 0 :(得分:0)
首先,您的规则是:^/?news/?
,但是,您将转到网址/newview/
。显然这不会起作用,因为“newview”绝对不是“新闻”。
其次,您的分组。(.*)
匹配id/3
,您反对它。显然,id/3
不是id=3
。尝试:
RewriteRule ^/?newview/id/([0-9]+)$ /index.php?controller=Listings&action=news&id=$1 [L,QSA]