Favicons display many elements of the dark, early days of the Internet. Typically a 16×16 pixel image in ICO format (wtf is that?), they were introduced back in 1999 with Internet Explorer 5. More recently mobile browsers have followed in this unholy tradition by introducing more favicon files, bringing the list of files needing to be created / handled to:
Whilst they do provide a nice little visual logo space for your website or company, you may sometimes think they aren’t worth the bother. One unexpected problem: An Apache error log full of 404 errors from web browsers trying to locate /favicon.ico, /apple-touch-icon-precomposed.png and /apple-touch-icon.png files in your website’s root directory.
A simple way to prevent this is to add the following code to your apache virtualhost configuration:
Redirect 404 /favicon.ico <Location /favicon.ico> ErrorDocument 404 "favicon does not exist" </Location> Redirect 404 /apple-touch-icon-precomposed.png <Location /apple-touch-icon-precomposed.png> ErrorDocument 404 "apple-touch-icon-precomposed does not exist" </Location> Redirect 404 /apple-touch-icon.png <Location /apple-touch-icon.png> ErrorDocument 404 "apple-touch-icon does not exist" </Location>
Whilst this solution seems the most technically correct, it still means your server is going to be hit with constant 404 requests for the non-existant files on every page and frame load, although thankfully they should no longer be clogging up error logs. A more pragmatic approach is to create 3 blank files, 1 in ICO format and 2 in PNG format, placing them in your website’s root public directory as favicon.ico, apple-touch-icon-precomposed.png and apple-touch-icon.png. A good tip is to set the Expires header to sometime in the distant future to avoid any further favicon requests.
You will also need to add the following code to your page:
<link rel="shortcut icon" href="#" />
Now finally you can live in peace from bombardment of favicon requests …until browser makers start adding new favicon types.