nginx error_page in php and ? changing to &

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


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 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
		root /home/x/public_html;
		include /etc/nginx/fastcgi_params;
		fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME /home/x/public_html


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:, server:, request: "GET /error.php&/413
HTTP/1.1"    , host: ""

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

Any thoughts?
Thanks, Pat.

More information about the nginx mailing list