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.
2 Answers 2
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']
-
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– Elliot2009年10月21日 07:26:26 +00:00Commented 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
Mikey C– Mikey C2013年10月01日 11:03:53 +00:00Commented Oct 1, 2013 at 11:03
Just checking but it should be $_SERVER["QUERY_STRING"] - does your actual code include the $?
-
Yes, it does. I left out the $ in the question because phpinfo() leaves it out.Elliot– Elliot2009年10月18日 03:03:03 +00:00Commented Oct 18, 2009 at 3:03