nginx error_page in php and ? changing to &

Patkob patkob at interia.pl
Sat Sep 25 17:45:56 MSD 2010


Hello,

I haven't found solution for this problem, but if it was discussed
before, please direct me to the correct thread.

I'm using nginx/0.7.65 on debian lenny, and PHP 5.2.6-1+lenny9 with
Suhosin-Patch 0.9.6.2. Here's fragment of my config (username changed
to 'x'):

server {
	[...]

	error_page 400 /error.php?/400;
	error_page 401 /error.php?/401;
	error_page 402 /error.php?/402;
	[... and so on ...]
	error_page 413 /error.php?/413;
	[...]

	location = /error.php
	{
		internal;
		root /home/x/public_html;
		include /etc/nginx/fastcgi_params;
		fastcgi_pass 127.0.0.1:9000;
		fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME /home/x/public_html
$fastcgi_script_name;
	}

	[...]
}

Everything is working great, when user tries to open non-existing
image my custom error page from /error.php?/404 shows up:

["REQUEST_URI"] => string "/gfx/notexistingfile"
["SCRIPT_FILENAME"] => string "/home/x/public_html/error.php"
["QUERY_STRING"] => string "/404"

But... for a strange reason (and my question to you is "WHY"),
sometimes i get in error.log something like this:

2010/09/25 10:43:54 [error] 12227#0: *64647 open() "/home/x/
public_html/error.php&/413" failed (2: No such file or directory),
client: 77.255.51.154, server: x.pl, request: "GET /error.php&/413
HTTP/1.1"    , host: "www.x.pl"

Why is nginx changing "?" into "&" in this case? I have even tried to
rewrite this back, but it wasn't really working.

if ($request_uri ~ ^/error\.php) {
	rewrite ^/error\.php.(.*)$ /error.php?$1
	break;
}

Any thoughts?
Thanks, Pat.




More information about the nginx mailing list