Cafn
Cafn

Reputation: 206

Cakephp Favicon on Internet Explorer

I'm trying to setup favicon on IE, since I allways get the warnings saying that it's not being accessed.

2017-03-06 19:43:25 Error: [Cake\Routing\Exception\MissingControllerException] Controller class Favicon.ico could not be found.

On other browsers, they are working no problem.

I have the following code

<link rel="icon" type="image/x-icon" href="url/favicon/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/x-icon" href="url/favicon/favicon-16x16.png" sizes="16x16">
<link rel="shortcut icon" href="url/favicon/favicon-16x16.png" type="image/x-icon">

Yet, it stills gives the error.

Any ideias?

Upvotes: 0

Views: 188

Answers (2)

Cafn
Cafn

Reputation: 206

Thanks everybody for the answers

Fixed the problem with routes

Router::redirect(
    '/favicon.ico',
   'url.ico', array('status' => 302)
);

Upvotes: 0

philippe_b
philippe_b

Reputation: 41318

TL;DR

Create an icon file named favicon.ico and put it at the root of your site.

In details

By convention, IE looks for /favicon.ico when it visits a site. Modern versions also supports PNG icons, so this issue is harmless and can be ignored.

What you can do to fix this issue:

  • Provide a favicon.ico at the root of your web site. This will prevent the failure while giving some browsers what they are looking for.
  • Make CakePHP ignore the error. Apparently the access tricks CakePHP, which thinks this must be routed to some PHP code. If CakePHP could consider this access as what it is (ie. an access to a static file), it would just end up as it should: a regular 404 error. No one like 404, but at least this is the right behavior, unlike a quest for an hypothetical controller named Favicon.ico.

Upvotes: 1

Related Questions