2

我在 .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"

这里发生了什么,我如何修改我的规则以使其行为?

4

1 回答 1

3

您需要添加原始查询字符串:

RewriteRule (.*) index.php?q=$1 [L,QSA]
                                   ^^^ here
于 2013-05-02T18:33:13.307 回答