我在 .htaccess 文件中使用以下重写规则将所有请求发送到位于根目录的 index.php 文件:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?q=$1 [L]
正如我所料,像 example.com/users 这样的 url 将导致 php 接收 ["q"]=> string(5) "users"
作为 $ _GET 变量。
另一方面,像 example.com/users?fu=bar 这样的 URL 不会导致 php 接收
["q"]=> string(5) "users",
["fu"]=> string(3) "bar"
这里发生了什么,我如何修改我的规则以实现这种方式?
最佳答案
您需要添加原始查询字符串:
RewriteRule (.*) index.php?q=$1 [L,QSA]
^^^ here
关于php - mod_rewrite 之后查询字符串被忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16345260/