5

I've done quite a bit of searching and reading on trying to find a solution but have not come up or across with anything that has worked for me just yet. I am building a site that carries a colored themed structure. I would like to have each page use a different colored favicon for it's corresponding page color. For example:

  • Page 1 / background color = blue -> blue favicon.
  • Page 2 / background color = red -> red favicon.
  • Etc.

The closest I came across was a using a PHP method and appending a number to the end of the icon file -

<?php echo '<link rel="shortcut icon" href="http://www.yoursite.com/favicon.ico?t=' . time() . '" />; ?>

Unless the php is wrong, this didn't seem to work for me. Im not the strongest in PHP but if anyone has any suggestions or relevant reading on this it would be appreciated.

Halvor Holsten Strand
  • 19,829
  • 17
  • 83
  • 99
Eric H
  • 147
  • 1
  • 1
  • 12

1 Answers1

12

It's simpler than you think. No PHP required. Just change the URL to point to the path of the favicon you want.

On the blue favicon page:

<link rel="icon" href="http://www.yoursite.com/blue_favicon.ico" />

On the red favicon page:

<link rel="icon" href="http://www.yoursite.com/red_favicon.ico" />

Browsers, by default, look for /favicon.ico. But if you specify a different path and file it will use that instead.

John Conde
  • 217,595
  • 99
  • 455
  • 496