gpt4 book ai didi

php - 查询字符串在 mod_rewrite 后被忽略

转载 作者:行者123 更新时间:2023-12-04 04:59:18 25 4
gpt4 key购买 nike

我在我的 .htaccess 文件中使用以下重写规则将所有请求发送到位于根目录的 index.php 文件:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?q=$1 [L]

正如我所料,网址如 example.com/users 将导致 php 接收 ["q"]=> string(5) "users"作为 $_GET 变量。

这样的 URL example.com/users?fu=bar 另一方面不会导致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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com