1

我一直在寻找整个互联网,但我找不到解决方案。

我一直在尝试将查询字符串作为 php 中的另一个 $_GET 值传递。例如localhost/find/book转换为index.php?url=find/book但这还不足以达到我的目的。当我尝试做类似localhost/find/book?cols=name,library我希望将其转换为index.php?url=find/book?cols=name,library但它转换为index.php?url=find/book它只是省略第二个查询字符串的事情时。

我很确定几个月前我这样做了,并且奏效了。但现在它只是没有,我不知道为什么。

这是我的重写规则:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]

提前致谢。

4

1 回答 1

1

QSA您已经使用的选项就是这样做的。

但是,没有第二个查询字符串这样的东西,因此您的 url 不会转换为:

index.php?url=find/book?cols=name,library

而是改为:

index.php?url=find/book&cols=name,library
                       ^ here

请注意,您必须注意输出有效的查询字符串(例如urlencode在 php 中使用),否则您的应用程序可能不会像您认为的那样运行。例如,您的逗号应该编码为,%2C但您应该urlencode注意这一点。

于 2013-07-02T15:01:29.970 回答