Why does my rewrite rule disables additional $_GET data?

我的未来我决定 提交于 2020-01-04 13:08:11

问题


I'm using this rewrite rule for my whole domain:

RewriteRule ^([A-Za-z0-9/-]+)$ /index.php?path=$1

So for example, my urls look like this:

http://www.example.com/page/subpage/4/anything/

The problem is when I want to manually add a specific $_GET, like this:

http://www.example.com/page/subpage/4/anything/?also=admin

I remember this has worked on some sites I've been developing, but it doesn't work here.

How can I fix my RewriteRule so that I can add $_GET data like this?


回答1:


Use Query String Append (QSA):

RewriteRule ^([A-Za-z0-9/-]+)$ /index.php?path=$1 [QSA]



回答2:


Add as second rule that looks for URLs with ? in them:

RewriteRule ^([A-Za-z0-9/-]+)\?(.*) /index.php?path=$1&$2


来源:https://stackoverflow.com/questions/13571632/why-does-my-rewrite-rule-disables-additional-get-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!