How to prevent favicon.ico requests? 404 Favicon Errors

  • How to prevent File not found (404) for favicon.ico in web server access and error logs

    If there is no favicon.ico file at the root level of a website, when a webpage is bookmarked a 404 (file not found) error may be generated (depending on the browser used). This error will not be visible to the user, but will be shown in the website server log (traffic report).

    Is it possible to prevent the browser to make a request for the favicon of my site? Yes it is possible, there are more than one ways to solve this favicon request and 404 not found error messages in log files.
    1- Using an invisible favicon.ico file

    2- Using .htaccess

    A very simple solution is put the below code in your .htaccess file
    <IfModule mod_alias.c>
        RedirectMatch 403 favicon.ico

    3- Using html codes

    Solve error messages working with all recent browsers like Safari, Chrome and Firefox:

    <link rel="icon" href="data:;base64,=">

    If you need your document to validate against HTLM5 use the following code:

    <link rel="icon" href="data:;base64,iVBORw0KGgo=">
    The favicon.ico is an image that stays in the root of your server. If you don't care about it the browser will still request it, so it's better not to respond with a 404 Not Found.