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

Sven 'Darkman' Michels sven at darkman.de
Sun Jul 31 12:53:45 UTC 2011


Hi,

maybe i'm to stupid or missing something, but actually i try to setup a set
of custom error_pages. To keep it simple, i put them all into one directory
and named them like the error i want to catch with them.

>From the examples, i found setups like this:
error_page   404          /404.html;
error_page   502 503 504  /50x.html;

but since i don't want them to be in the root of my virtual host, i put
them into a different directory (outside of root). For that reason, i
created a config like this:
error_page 503 /status-503.html;
error_page 403 /status-403.html;
location = /status-503.html {
    root /var/www/statuspages;
}
location = /status-403.html {
    root /var/www/statuspages;
}

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
with ^~ /status/, = /status/ and things like error_page 503 @status/503.html
and location @status - with no success.

At the end i would like to have some internal location or something like that
to avoid conflicts with real existing directorys - if possible. And just one
location for my error pages.

Is that possible at all or should i just use multiple locations and everything
is fine...?

Thanks and regards,
Sven



More information about the nginx mailing list