3

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.

tereško
58.5k26 gold badges100 silver badges151 bronze badges
asked Oct 17, 2009 at 6:25

2 Answers 2

12

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

answered Oct 17, 2009 at 6:30
2
  • 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) Commented Oct 21, 2009 at 7:26
  • RELATED: I was having this problem with Apache; turned out the RewriteBase line in .htaccess was messing it up: you can't say RewriteBase /#comment Commented Oct 1, 2013 at 11:03
0

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

answered Oct 17, 2009 at 12:33
1
  • Yes, it does. I left out the $ in the question because phpinfo() leaves it out. Commented Oct 18, 2009 at 3:03

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.