I want to server favicon from a different place rather than the root
folder.
As I explored I have two options
-
location = /favicon.ico { alias /var/www/media/images/favicon.X.ico; }
-
rewrite ^/favicon.ico /var/www/media/images/favicon.X.ico last;
As I understand the second one needs an additional regex check for every
request to check if the url is favicon or not (imagine that we have a
rewite
of ^/(.).(.) and thus the favicon rewite must be first).
How the location works? Does it also should be checked on every request?
In general, which solution is better ?
Posted at Nginx Forum:
Anton Y. Wrote:
rewrite ^/favicon.ico /var/www/media/images/favicon.X.ico last;
This is wrong - you can rewrite to other location, not to path on file
system.
Anyway rewrite does not need here, use location.
Sorry, my bad! In the second case, I meant rewrite ^/favicon.ico
/media/images/favicon.X.ico last;
but anyway, it seems that location works better in general.
Posted at Nginx Forum:
On 04/01/13 16:51, etrader wrote:
I want to server favicon from a different place rather than the root folder.
As I explored I have two options
-
location = /favicon.ico { alias /var/www/media/images/favicon.X.ico; }
It is working option.
-
rewrite ^/favicon.ico /var/www/media/images/favicon.X.ico last;
This is wrong - you can rewrite to other location, not to path on file
system.
Anyway rewrite does not need here, use location.
Yes, location is better and even faster in general.
Andrejs
Posted at Nginx Forum: