nginx set location of /favicon.ico

Revision history
Tags: nginx html

Browsers try to get /favicon.ico by default if nothing else is specified with the <link rel="shortcut icon" href=... tag. So because I like to keep the root clean, I put the favicon in the /img folder.

location = /favicon.ico {
    alias /var/www/mysite/img/favicon.ico;
}

This is kinda nice, because I don’t have to do anything with the HTML.

If you have any comments or feedback, please send me an e-mail. (stig at stigok dotcom).

Did you find any typos, incorrect information, or have something to add? Then please propose a change to this post.

Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.