1

Going through 404 error on my site, I have noticed a bunch of problems with favicons:

/apple-touch-icon-120x120.png
/apple-touch-icon-120x120-precomposed.png
/apple-touch-icon-152x152.png
/apple-touch-icon-152x152-precomposed.png
/apple-touch-icon-precomposed.png
/apple-touch-icon.png
/favicon.ico

Interesting part is that I have the following code on every page

<link rel="shortcut icon" href="/public/img/favicon.ico">
<link rel="apple-touch-icon image_src" href="/public/img/apple-big.png">

But I see that sometimes in the logs I see "GET /public/img/favicon.ico HTTP/1.1" 200 which means that icon is taken from correct location, but sometimes "GET /favicon.ico HTTP/1.1" 404.

I searched through the whole codebase trying to find where else favicon could be called, but with not luck. Any idea what might be wrong?

P.S. added user agents: "GET /favicon.ico HTTP/1.1" 404 409 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0"

  • Is you image at /public/img/favicon.ico in the correct format and return the appropriate Content-Type header? – MrWhite May 19 '14 at 9:12
  • Yes. it is correct format and content type. If I just enter the url in the browser I see that "GET /public/img/favicon.ico HTTP/1.1" 200 is generated in logs. This is why I am so puzzled. – Salvador Dali May 19 '14 at 9:25
  • 1
    As Mike suggests below, some user agents (inc. bots, etc.) will always request the favicon.ico file in the root of the site, regardless of the link element. The fact that your 404 appears to be Firefox is a bit of a puzzle - unless it is a bot pretending to be Firefox (check the IP)? Which made me wonder whether the Content-Type for your linked file was an issue? Is the same visitor not requesting your linked file at all? – MrWhite May 19 '14 at 9:49
1

It would be worth looking at the user-agent values for those requests causing the 404's. As previously asked/answered, browsers will normally follow the <link> location before any default request is made against the root folder of the site.

The error logs you are seeing are due to your file locations being in other directories. Most browsers will find them as they've parsed your HTML and located the appropriate <link> declaration, but others may not.

[EDIT/UPDATE FOR EXPLICIT ANSWER]
Move or redirect requests for your icons to the root folder so that the following resolve:

<link rel="shortcut icon" href="/favicon.ico">
<link rel="apple-touch-icon image_src" href="/apple-touch-icon-precomposed.png">

Then add/provision for the other requests as outlined here.

  • Thank for your help. I added info about user-agents. Sorry, but I still did not get how can I solve my problem. – Salvador Dali May 19 '14 at 1:38
  • Added edits to help solve problem – Mike Hudson May 20 '14 at 6:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.