Why is PHP not seeing my query string?

你说的曾经没有我的故事 提交于 2019-12-23 19:31:59

问题


This phpinfo() demonstrates the problem.

I'm passing the URL a query string of:

?qwerty=asdfg

As a result, I'm expecting it to list these two PHP variables:

_REQUEST["qwerty"] asdfg
_GET["qwerty"] asdfg

And also this query string:

_SERVER["QUERY_STRING"] qwerty=asdfg

However, it's not working. None of these variables seem to be set at all.

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.

My question is: why isn't PHP seeing the query string?

And how do I fix it?

Here's a normal phpinfo() which successfully sees the query string. This is running on a different server, which is running Apache.


回答1:


http://redmine.lighttpd.net/wiki/lighttpd/Docs:ModRewrite

At the bottom:

"If you wanna pass the Query String (?foo=bar) to the rewrite destination you have to explicitly match it:"

And the alternative is to read it through $_SERVER['REQUEST_URI']




回答2:


Just checking but it should be $_SERVER["QUERY_STRING"] - does your actual code include the $?



来源:https://stackoverflow.com/questions/1581571/why-is-php-not-seeing-my-query-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!