0

I set an icon like that:

<link rel="icon" type="image/x-icon" href="/media/icon.ico">
<link rel="shortcut icon" type="image/x-icon" href="/media/icon.ico">

and I also tried this:

<link href="/media/icon.ico" rel="shortcut icon" type="image/x-icon" />

It works only in some parts of my website, but I don't know what I'm doing wrong. Is there something that I have to consider?

I use PHP and HTML. I don't know if it's coincidence or not, but it works with every HTML file and only with some of the PHP files.

Can anybody help me?

shivan

Anonymous
  • 11,748
  • 6
  • 35
  • 57
user2871190
  • 241
  • 2
  • 5
  • 19
  • This would only be a problem with your PHP files if they're generating incorrect HTML. There's no way to tell from what you've posted here. Note that the browsers don't update the FavIcon every time they visit a page. It might be a couple of days before you see a change. –  May 04 '14 at 20:11

4 Answers4

1

You'll need to make sure the URL (href) is valid for the page you are viewing. Remember / is site level (/media/icon.ico = http://yourdomain.com/media/icon.ico).

Also make sure it is a valid .ico file. I recommend trying a .jpg file instead. (.png, .jpg, .gif and .ico are all valid favicon formats)

As well, depending on the icon size, it may not work in all browsers. 16x16 is the recommend size for favicons, but 32x32 may work as well.

Here is a link that should tell you everything about favicons: http://perishablepress.com/everything-you-ever-wanted-to-know-about-favicons/

arleslie
  • 460
  • 1
  • 4
  • 16
1

If it only appears for your html pages and not your php ones, then you may be adding the link tag incorrectly or it may also be missing.

I suggest you use the developer tools of your browser (right-click anywhere on your page and choose Inspect Element - Chrome, Firefox) when you're on your php pages and check if you see the tag added correctly having the exact same path set there as in your html pages. Using developer tools you should also be able to hover over the link and it would tell you if the image existed or not.

I bet the path will be incorrect somehow depending on the placement of your php files versus the html ones and the icon.

benomatis
  • 5,536
  • 7
  • 36
  • 59
0

Try accessing those pages from another browser. Also, try accessing them from a browser in incognito/private mode.

If you do see the favicon, try cleaning your browser's cache - it could be that something is left over from the last time you browse those pages (i.e. before you added the favicon to the HTML).

Traveling Tech Guy
  • 27,194
  • 23
  • 111
  • 159
0

I had trouble getting this to work for me without using a direct link.

For example on my site: http://adamgressen.com/

I reference the image with a direct link:

<LINK rel="SHORTCUT ICON" href="http://adamgressen.com/favicon.ico">

You definitely want to clear your cache if you're testing locally because you may not see the changes for a while otherwise.

agressen
  • 459
  • 1
  • 5
  • 17