Welcome! Log In Create A New Profile

Advanced

Re: Nginx rewrite rule for favicon.ico files

August 31, 2012 09:31AM
> Would this help? [note: from memory, not tested]
>
> location = /favicon.ico {
> try_files /images/$server_name.ico /favicon.ico =204;
> }
>
> M.
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

I have several vhosts, this is part of the config file for vhost in question:

server_name sub1.domain.com *.mydomain.com mydomain.com sub2.domain.com;


if ($host = www.mydomain.com){
rewrite ^/favicon.ico$ /favicon_mydomain.ico break;
}

if ($host = boat.mydomain.com){
rewrite ^/favicon.ico$ /favicon_boat.ico break;
}

if ($host = car.mydomain.com){
rewrite ^/favicon.ico$ /favicon_car.ico break;
}

etc...

I plan to put all .ico files in /images/ dir.
favicon_mydomain.ico
favicon_boat.ico
favicon_car.ico

and many more...


So what I need is next:
when request is happens for car.mydomain.com,
nginx searches for /images/favicon_car.ico and it serves it if exists,
if not than serves regular favicon.ico.

Please help...
Subject Author Posted

Nginx rewrite rule for favicon.ico files

nexon August 31, 2012 06:28AM

Re: Nginx rewrite rule for favicon.ico files

Igor Sysoev August 31, 2012 06:44AM

Re: Nginx rewrite rule for favicon.ico files

nexon August 31, 2012 07:27AM

Re: Nginx rewrite rule for favicon.ico files

Igor Sysoev August 31, 2012 07:34AM

Re: Nginx rewrite rule for favicon.ico files

nexon August 31, 2012 07:44AM

Re: Nginx rewrite rule for favicon.ico files

Igor Sysoev August 31, 2012 08:30AM

Re: Nginx rewrite rule for favicon.ico files

nexon August 31, 2012 09:10AM

Re: Nginx rewrite rule for favicon.ico files

Igor Sysoev August 31, 2012 10:02AM

Re: Nginx rewrite rule for favicon.ico files

nexon August 31, 2012 10:50AM

Re: Nginx rewrite rule for favicon.ico files

Igor Sysoev August 31, 2012 10:58AM

Re: Nginx rewrite rule for favicon.ico files

Reinis Rozitis August 31, 2012 06:56AM

Re: Nginx rewrite rule for favicon.ico files

nexon August 31, 2012 09:13AM

Re: Nginx rewrite rule for favicon.ico files

VBart August 31, 2012 09:20AM

Re: Nginx rewrite rule for favicon.ico files

nexon August 31, 2012 10:52AM

Re: Nginx rewrite rule for favicon.ico files

Mark Alan August 31, 2012 09:16AM

Re: Nginx rewrite rule for favicon.ico files

nexon August 31, 2012 09:31AM

Re: Nginx rewrite rule for favicon.ico files

nexon August 31, 2012 10:54AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 117
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready