Nginx rewrite rule for favicon.ico files

Reinis Rozitis r at roze.lv
Fri Aug 31 10:54:22 UTC 2012


> That rule must do:
> 1.For subdomains example1,example2... to check in location 
> /images/$host.ico is there a favicon_example.ico file and serve it.
> 2.If there is no such file, than to serve just a plain favicon.ico file.

>From you description I don't fully understand what exactly is your current 
file structure but you can use try_files ( 
http://wiki.nginx.org/HttpCoreModule#try_files ) and add the $host variable 
in whatever place is needed.

For example:

location /favicon.ico {
    try_files /images/$host/favicon_example.ico /favicon.ico;
}


rr 



More information about the nginx mailing list