If you run an Apache server then you have no doubt seen the following error message a thousand times in your error.log file.
File does not exist: /var/www/favicon.ico
The reason? You have not created a favicon, also known as a website icon, for your website. It’s the icon that displays in the address bar of your web browser when you connect to a website. A web browser will request this icon file from every website.
You have two choices. You can create a website icon for each of your websites, or you tell Apache not to log that event as an error message.
If you choose to create one. Use a program such as Gimp and create a 16×16 pixel image and save it as a .ico filetype. Then upload that file to the DocumentRoot of your website. You will need one for each VirtualHost. If you don’t have Gimp, there are online resources such as favicon.cc where you can create a .ico file and download it for your own use.
As you know by now, not having a favicon.ico file, won’t stop web browsers from requesting it each time. But you can tell Apache not to log the event as an error message. You will still see the request in the access.log, but at least you will have a cleaner error.log file.
Add the following block of code to each VirtualHost, or at least the ones which don’t have a favicon file.
Redirect 404 /favicon.ico
ErrorDocument 404 "No favicon"
Don’t forget to restart apache after making the change. If you want make a “global” change, which would apply to any and all VirtualHosts, you can create a file in Apache’s conf.d folder with a name such as nofavicon.conf and then add that block of code to the file. That would disable favicon across the board and save you from having to edit each VirtualHost.
Most of my sites don't have favicons. I think it's nice to have one, but designing an icon that looks good and matches a site theme takes time and effort better spent elsewhere. My pixel-pushing powers are not at a level where making one is easy and I'd rather have the default icon than an ugly one, thank you very much.When Internet Explorer introduced favicons, it regrettably used fixed location probing to detect the presence of page icons. Other browsers have since adopted the feature, and if my server logs are any indication Firefox is even more obsessive-compulsive about them than IE. Nearly every browser visit will be associated with requests for favicon.ico, which translates into a lot of requests on a busy site.What does this mean for sites without favicons? For each and every one of those requests Apache will look for the file favicon.ico, find that it still does not exist, and return a 404 Not Found error page. If you use custom error documents (a user-friendly thing to do), that page could very well be several kilobytes in size and will not be seen by the visitor. A further annoyance is that the aforementioned failed file-finding attempt will clutter up the error log with reams of "File does not exist" errors.You can get rid of the unnecessary processing and traffic as well as the error log entries by using the following Apache configuration incantations: # Don't bother looking for favicon.ico Redirect 404 /favicon.ico # Don't bother sending the custom error page for favicon.ico