为什么PHP看不到我的查询字符串? [英] Why is PHP not seeing my query string?
问题描述
此 phpinfo()演示问题.
我正在向URL传递以下查询字符串:
I'm passing the URL a query string of:
?qwerty=asdfg
因此,我希望它列出以下两个PHP变量:
As a result, I'm expecting it to list these two PHP variables:
_REQUEST["qwerty"] asdfg
_GET["qwerty"] asdfg
还有此查询字符串:
_SERVER["QUERY_STRING"] qwerty=asdfg
但是,它不起作用.这些变量似乎都没有设置.
However, it's not working. None of these variables seem to be set at all.
我正在使用lighttpd.这可能与问题无关,但可能与问题无关,但我的greengar.com-lighttpd.conf看起来像这样,因为我在该域的大多数页面上都使用WordPress:
I'm using lighttpd. This may or may not be related to the problem, but my greengar.com-lighttpd.conf looks like this, because I'm using WordPress for most of the domain's pages:
### Generated by Elliot
### Wordpress: http://www.greengar.com
url.rewrite += (
"^/(wp-.+).*/?" => "$0",
"^/(blog/wp-.+).*/?" => "$0",
"^/(.*.php)" => "$0",
"^/(.*.pdf)" => "$0",
"^/(.*.png)" => "$0",
"^/(.*.html)" => "$0",
"^/(.*.ico)" => "$0",
"^/(.*.gif)" => "$0",
"^/(.*.txt)" => "$0",
"^/(images).*/?" => "$0",
"^/(sitemap.xml)" => "$0",
"^/(xmlrpc.php)" => "$0",
"^/(.+)/?$" => "/index.php/$1"
)
再次,我不确定这是否与问题有关.
Again, I don't know for sure whether this is related to the problem.
我的问题是:PHP为什么看不到查询字符串?
My question is: why isn't PHP seeing the query string?
该如何解决?
这是正常的 phpinfo()成功查看查询字符串.它运行在另一台运行Apache的服务器上.
Here's a normal phpinfo() which successfully sees the query string. This is running on a different server, which is running Apache.
推荐答案
http://redmine.lighttpd.net/wiki/lighttpd/Docs:ModRewrite
在底部:
如果要将查询字符串(?foo = bar)传递给重写目标,则必须明确匹配它:"
"If you wanna pass the Query String (?foo=bar) to the rewrite destination you have to explicitly match it:"
另一种选择是通过$ _SERVER ['REQUEST_URI']
And the alternative is to read it through $_SERVER['REQUEST_URI']
这篇关于为什么PHP看不到我的查询字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!