Search code examples
phpcodeigniterroutesfavicon

Preventing 404 Page Not Found: Faviconico/index in CodeIgniter


I have a CodeIgniter 3 application with log_threshold of 1. Most of the logs I get are 404 Page Not Found: Faviconico/index. I want to receive 404s in my logs, but not this one as it's not particularly useful or informative. I've created the following routes.

$route['Faviconico'] = 'general/empty_response';
$route['Faviconico/index'] = 'general/empty_response';

This is the general controller method empty_response.

// Serves nothing
public function empty_response()
{
    return false;
}

Visiting http://example.com/Faviconico/index directly in the browser no longer cause the log where as it use to, but somehow users are still causing this log to happen.

How can I prevent logging of 404 Page Not Found: Faviconico/index?


Solution

  • Many browsers look for a favicon to show next to the address bar. Add a favicon.ico to your root directory and that error should disappear.