default page

Adam Setzler adam.setzler at gmail.com
Tue Jul 1 17:51:33 MSD 2008


Do this to return No Content...

location = /favicon.ico {
       return 204;
}

Or this to do basically the same, which spits out an empty gif from
memory...

location = /favicon.ico {
      empty_gif;
}


On Tue, Jul 1, 2008 at 8:27 AM, Marcos Neves <marcos.neves at gmail.com> wrote:
>
> My current solution works:
>
> location = /favicon.ico {
>         if (!-f $request_filename) {
>           rewrite ^.*$ /favicon.ico.default;
>         }
>       }
>       location = /favicon.ico.default {
>         internal;
>         alias html/favicon.ico;
>         break;
>       }
>
> but would be nice if possible to do this:
>
>
> location = /favicon.ico {
>         if (!-f $request_filename) {
>         alias html/favicon.ico;
>         break;
>         }
>
> But alias can´t be used inside an if. Why that?
>
> On Tue, Jul 1, 2008 at 10:15 AM, Igor Sysoev <is at rambler-co.ru> wrote:
> > On Tue, Jul 01, 2008 at 05:09:33PM +0400, Maxim Dounin wrote:
> >
> >> Hello!
> >>
> >> On Tue, Jul 01, 2008 at 08:03:23AM -0300, Marcos Neves wrote:
> >>
> >> >your solution is DRY, but I?m not sure if it?s right to send a 404
code,
> >> >is it?
> >>
> >> Feel free to use
> >>
> >>    error_page 404 = html/favicon.ico;
> >>
> >> instead (note the '=').
> >>
> >> See http://wiki.codemongers.com/NginxHttpCoreModule#error_page for
> >> details.
> >
> > No, html/favicon.ico will not work. It should be redirected to something
like
> > /html/favicon.ico, and then some location /html/... should be described.
> >
> >> Maxim Dounin
> >>
> >> >
> >> >On Mon, Jun 30, 2008 at 5:24 PM, Cliff Wells <cliff at develix.com>
wrote:
> >> >>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
> >> >>
> >> >>
> >> >>
> >> >>
> >> >
> >> >
> >> >
> >> >--
> >> >Marcos Neves
> >> >+55 44 3263-8132
> >> >+55 44 9918-8488
> >> >
> >
> > --
> > Igor Sysoev
> > http://sysoev.ru/en/
> >
> >
>
>
>
> --
> Marcos Neves
> +55 44 3263-8132
> +55 44 9918-8488
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20080701/9243430e/attachment.html>


More information about the nginx mailing list