nginx error_page in php and ? changing to &

Maxim Dounin mdounin at mdounin.ru
Fri Oct 1 15:59:12 MSD 2010


Hello!

On Sat, Sep 25, 2010 at 06:45:56AM -0700, Patkob wrote:

> 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"

Log message clearly says that was original request from browser, 
note 'request: "GET /error.php&/413 HTTP/1.1"'.

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

Most likely it wasn't nginx, at least not due to the config 
snippet you provided.

I would recommend looking into you error.php script to check if it 
issues any redirects (e.g. to use canonical server name).

Maxim Dounin



More information about the nginx mailing list