I keep seeing favicon warnings in my apache log. How do I get rid of those? Do I have to have a favicon for my site?
You don't really need it, but as others have said, some browsers will ask for it even if it's not specified in <link rel="shortcut icon" />
.
I'm not an expert, but I played with mod_rewrite a bit, and here's what you can do:
# turn on the mod_rewrite module
RewriteEngine On
# if requested file is not an existing file
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
# and it's name is favicon.ico, send an empty 410 GONE response to the browser
RewriteRule .*favicon\.ico$ - [G]
I only tried this on my localhost: first request resulted in 410, but for all following ones, browser does not ask for that file, because it remembers it's gone.
I'm not sure this is how you're supposed to use 410 GONE status, nor that it will work 100%.
/favicon.ico
is one of the artifacts of the Browser Dark Ages (cca 2000). While there is no way to prevent the browser requests, creating a 0-byte file named favicon.ico ends the flow of 404 errors (as the file exists), but no favicon will be shown by the browsers for your site.
Looking at your logs, you will probably see such 404 errors:
favicon.ico
: Internet Explorer, Chrome...apple-touch-icon.png
: iOS devices, Android, maybe some other devicesapple-touch-icon-precomposed.png
: iOS devices, Android, maybe some other devicesapple-touch-icon-76x76.png
: iOS, maybe some other devicesapple-touch-icon-120x120.png
: iOS, maybe some other devicesapple-touch-icon-152x152.png
: iOS, maybe some other devicesIf you absolutely don't want to add a favicon to your site, you can apply one the the solution described in the other answers:
However, favicon are so common nowadays that you probably want to add one to your site. This favicon generator creates all these files at once. Full disclosure: I am the creator of this site.
Webbrowsers use this to display the image you see in your favorites as well as the icon of your tab. e.g. when you go to stackoverflow the cool icon you see in the tab as shown : is automatically fetched by my browser (chrome) using the url : https://stackoverflow.com/favicon.ico . Its pretty standard so in case you don't want it in your log you should put some icon and rename it as favicon.ico in the httpdocs.
Not really need it.
However it is used on your site (the warnings).
Check the source of your website to see if it contains:
<link rel="shortcut icon" href="favicon.ico">
In the head section of the page.
Remove that line or add the favicon to prevent erros in your log.
You don't need to, no, but some browsers will request /favicon.ico
automatically, so the errors are pretty much unavoidable.