default page

Cliff Wells cliff at develix.com
Tue Jul 1 00:24:10 MSD 2008


On Mon, 2008-06-30 at 17:16 -0300, Marcos Neves wrote:
> I´m doing this to show a default favicon.ico, when the site doesn´t have one:
> 
>        location = /favicon.ico {
>           if (!-f $request_filename) {
>             rewrite ^.*$ /favicon.ico.default;
>           }
>         }
>         location = /favicon.ico.default {
>           internal;
>           alias html/favicon.ico;
>           break;
>         }
> 
> But I think it´s to ugly and far from DRY.
> Is there any way to short this code?

Not sure how "DRY" applies in this context...

What you probably want is something like this:

location = /favicon.ico {
   error_page 404 html/favicon.ico;
}

Cliff







More information about the nginx mailing list