我希望重写规则具有以下行为。
如果网址是:
/users
它会用 index.php?template=users 重写
如果是:
/users?id=2
它会用 index.php?template=users&id=2 重写,因为 URL 中有很多变量。所以这意味着即使我使用
/users?id=2&action=edit&something=no&something_else=yes
我希望传递所有这些变量,从而得到 /index.php?template=usersid=2&action=edit&something=no&something_else=yes
直到现在,我的 htaccess 规则一直是:
RewriteRule ^([^\.]+)$ index.php?template=$1
但是有了这个,我不能像我想要的那样使用带有问号的 URL。相反,我必须使用 /users&id=2,这看起来很傻。
我用谷歌搜索了很多,但解决方案要么不起作用,要么与我的情况不够相似,我无法调整它们并得到我想要的。