views:

321

answers:

2

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.

+8  A: 

http://redmine.lighttpd.net/wiki/lighttpd/Docs%3AModRewrite

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']

Erik
+1 for agreement! :D
thephpdeveloper
I spent a couple hours learning regexes so that I could confidently make the change that would match and pass along the query string. Here it is: "^/(.*.php)(\?(.*))?" => "$0", (replace line 6 of the code in my question)
Elliot
A: 

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

webmonkeyash
Yes, it does. I left out the $ in the question because phpinfo() leaves it out.
Elliot