Cascading error_page?

hi,

is it possible to create “cascading” error pages?

files are beeing requested like http://static.lovelybooks.de/covers/
9780/002/154/123/116x116.jpg

if the file is not beeing found under /covers/ (all dirs are
numeric) i’d like to look if the file is under /covers/btol/…
if it’s not there under /covers/knv
and finally under /covers/lastone
if a file is not beeing found under /lastone i’d like to return a
default image based on the requested size (3 possible sizes)

it seems like it’s not possible to change the error page multiple times.
is it also possible to set a non-404 header? even if the result is
beeing forwarded after an 404 error?

thanks

jodok

here’s my try:

 location /covers/(0|1|2|3|4|5|6|7|8|9])* {
     autoindex on;
     expires 1w;
     root /var/www/static.lovelybooks.de/covers;
     rewrite ^/covers(.*)$ $1;
     error_page 404 /covers/btol$uri;
 }

 location /covers/btol {
     root /var/www/static.lovelybooks.de/covers/btol;
     rewrite ^/covers/btol(.*)$ $1;
     error_page 404 /covers/knv$uri;
 }

 location /covers/knv {
     root /var/www/static.lovelybooks.de/covers/btol;
     rewrite ^/covers/knv(.*)$ $1;
     error_page 404 /covers/lastone$uri;
 }

 location /covers/lastone {
     root /var/www/static.lovelybooks.de/covers;
     rewrite ^/covers/lastone(.*)$ $1;

     location ~ /42x42\.jpg$ {
         error_page 404 /error/covers/42x42.jpg;
     }
     location ~ /116x116\.jpg$ {
         error_page 404 /error/covers/116x116.jpg;
     }
     location ~ /170x170\.jpg$ {
         error_page 404 /error/covers/170x170.jpg;
     }
 }


“Readability counts.”
– The Zen of Python, by Tim Peters

Jodok B., Lovely Systems
Schmelzhütterstraße 26a, 6850 Dornbirn, Austria
phone: +43 5572 908060, fax: +43 5572 908060-77

On Fri, Oct 26, 2007 at 04:03:35PM +0200, Jodok B. wrote:

default image based on the requested size (3 possible sizes)

it seems like it’s not possible to change the error page multiple times.
is it also possible to set a non-404 header? even if the result is
beeing forwarded after an 404 error?

recursive_error_pages on|off;

You may set them in some location or per server.

    root /var/www/static.lovelybooks.de/covers;
    rewrite ^/covers(.*)$ $1;
    error_page 404 /covers/btol$uri;
}

location /covers/btol {
    root /var/www/static.lovelybooks.de/covers/btol;
    rewrite ^/covers/btol(.*)$ $1;
    error_page 404 /covers/knv$uri;
  •     recursive_error_pages  on;
    
}

location /covers/knv {
    root /var/www/static.lovelybooks.de/covers/btol;
    rewrite ^/covers/knv(.*)$ $1;
    error_page 404 /covers/lastone$uri;
  •     recursive_error_pages  on;
    
}

location /covers/lastone {
    root /var/www/static.lovelybooks.de/covers;
    rewrite ^/covers/lastone(.*)$ $1;
  •     recursive_error_pages  on;

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs