我想从nginx返回自定义图标,所以我添加了以下内容:
location ~ ^/favicon.ico {
expires 2w;
access_log off;
try_files $uri /path/to/custom/ico.ico;
}
但是当我curl foo.com/favicon.ico
时我得到了404。怎么会这样?
答案 0 :(得分:0)
尝试
location = /favicon.ico {
expires 2w;
access_log off;
alias /path/to/custom/ico.ico;
}
我放置=
是因为using the “=” modifier it is possible to define an exact match of URI and location. If an exact match is found, the search terminates
。因此它可能会更快一些。