multiple error_pages in one directory - with one location - not possible?

Maxim Dounin mdounin at mdounin.ru
Sun Jul 31 13:15:04 UTC 2011


Hello!

On Sun, Jul 31, 2011 at 02:53:45PM +0200, Sven 'Darkman' Michels wrote:

[...]

> and put a page named "status-503.html" intoo the statuspages dir. This
> works so far. But i would like to keep the locations as less as possible.
> So i tried the following:
> 
> error_page 503 /status/503.html;
> error_page 403 /status/403.html;
> location = /status {
>     root /var/www/statuspages;
> }
> 
> But surprise, surprise, it didn't work. I got a 404 error. Of course i
> have renamed the status-xxx.html pages to xxx.html, too. I also tried it

Path to file is produced as <root> + <uri>.  In your case <uri> is 
"/status/503.html", so expected file path is 
"/var/www/statuspages/status/503.html".  Do you actually have this 
file?

>From what you wrote it looks like you instead have 
"/var/www/statuspages/503.html" file.  Using "alias" directive 
instead of "root" should resolve your problem.

See here for more information:

http://wiki.nginx.org/HttpCoreModule#root
http://wiki.nginx.org/HttpCoreModule#alias

Note well: nginx should log error to error_log if it isn't able to 
find requested file; looking into error_log is always a good idea.

Maxim Dounin



More information about the nginx mailing list