?
Solved

Favicon file in a subdirectory doesn't work

Posted on 2005-04-19
18
Medium Priority
?
1,650 Views
Last Modified: 2007-12-19
I'm using firefox. I have a site that has the favicon.ico in a subdirectory. I use the following bit of code in the "head" section of my HTML document:

<code>
<LINK REL="shortcut icon" HREF="/tmp/favicon.ico" TYPE="image/x-icon">
</code>

The favicon file never shows in the browser, however.  It works fine in the root directory.  But I need to be able to place the icon in a subdirectory.
0
Comment
Question by:nysus1
  • 6
  • 6
  • 2
  • +4
18 Comments
 
LVL 33

Expert Comment

by:sajuks
ID: 13813958
try clearing your page cache ,history,temporary internet files  and see if that helps...
0
 

Expert Comment

by:daemonerror
ID: 13814054
You should be able to do it my removing the /

<LINK REL="shortcut icon" HREF="tmp/favicon.ico" TYPE="image/x-icon">

It's abit odd, but it does work for me. Hope this helps.
0
 

Author Comment

by:nysus1
ID: 13814868
Well, after playing around with this some, I figured out the problem is the result of a complex interaction between my Apache server, DNS, and the software I'm using for the site, a CMS piece of software called Drupal.

I can get the favicon to show up but only if I use http://domain.com instead of http://www.domain.com.



0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Expert Comment

by:EnigmaSupport
ID: 13815729
If you have access to the web server running the CMS, check the caching settings which the server is using for the /tmp/ directory and files, if it's dis-allowing any caching of these files, then the favicon never actually gets stored on your local machine... - This tripped me up some time ago...
0
 

Expert Comment

by:hlslaughter
ID: 13816148
not sure if favicon will work in a subdir (didn't for me). move it to the server root and try:

<LINK REL="shortcut icon" HREF="favicon.ico" TYPE="image/icon">

that works for me :)

0
 

Expert Comment

by:hlslaughter
ID: 13816159
oh, and take it out of the <code> block, you don't need that.
0
 

Expert Comment

by:shanncan
ID: 13816704
Make sure that your paths to the subdirectory are correct.

If you have your webpages in the root directory then use:


./tmp/favicon.ico

If you have your webpages in a subdirectory of the root folder then use:


../tmp/favicon.ico



shanncan
0
 
LVL 1

Expert Comment

by:jazzmoney
ID: 13817610
As hlslaughter mentioned, remove the <link> section out of <code> block, as the only requirement is that it is placed in the <head> section of your html.
As you might already know, specifying the favicon.ico location is only necessary if it is not in the root (And as you specified, it is necessary).
Your implementation is perfect: <LINK REL="shortcut icon" HREF="/tmp/favicon.ico" TYPE="image/x-icon">
So if you have cleared out your cache, reloaded the page, tried (re)bookmarking the website, and yet are unable to see the favicon, the only remaining factor is the server configuration (as you mentioned).
Also, have you tested other browser's like firefox? Other browsers check for the favicon everytime, not only when being bookmarked as IE does. If you are using IE, humor me by dragging the default webpage icon located in front of your address in the address bar back to the address bar.
0
 
LVL 1

Expert Comment

by:jazzmoney
ID: 13817653
Sorry i skipped over your very first sentence: "I'm using firefox."
Sounds like it is the server setup. Let us know any specifics you have about your setup.
0
 

Author Comment

by:nysus1
ID: 13819058
Thanks, jazz.  This problem has been driving me crazy.  I agree with you.  I'm quite sure it's a server configuration problem.  Here's what I have:

entry in DNS for mydomain.com (the data actual IP address is not shown)
==============================================
...
www IN  A 123.456.789.000
...

relevant apache httpd.conf file entry
====================
<VirtualHost 123.456.789.000:80>
ServerName mydomain.com
ServerAlias mydomain.com, www.mydomain.com
...

Now, one quirk to this set up is that php session tracking is done separately for the "www.mydomain.com" and "mydomain.com".  So I can be logged in at "www.mydomain.com" yet still be logged out at "mydomain.com".  I used to have apache redirect "mydomain.com" to "www.mydomain.com" to solve this problem.  The favicon didn't work with that arrangement either, however.

Some other weirdness: the favicon does show up on the tabs in firefox, even after I clear the cache.  Also, I can get my favicon to show up in the address bar after I right click on the favicon (which is a picture of a piece of blank whit paper).  So, the favicon is able to load, but apparently not when I access a page.

Thanks.
0
 

Author Comment

by:nysus1
ID: 13819109
Other notes:

If I leave the site and come back to the home page by typing the address into the address bar, the favicon will appear in the address bar.  But if I click a link on the site, the favicon disappears.   If I click a link that takes me back to the home page from within the site, the favicon will NOT show.   However, if I look at the page info with a Ctrl+J, the favicon.ico file is listed in the media tab.  It shows the source as "Memory Cache".

You can (hopefully) see this for youself at communicateordie.com



0
 
LVL 1

Expert Comment

by:jazzmoney
ID: 13819580
Very strange. Works perfect without the www.
It will work with the www once the image has been cached.
0
 

Author Comment

by:nysus1
ID: 13819751
Is it working for you?  It's not working for me even without the www.

I have another domain that I'm using to test this problem: dondley.com (no www).  Can you get it to work there?  I can't.
There are two subdirectories "dondley.com/one" and "dondley.com/two" for the site.

And try this: from another site, type in 'dondley.com' into the address bar.  Watch the favicon closely.  It will momentarily load the icon and then it will disappear.  I don't get it.
0
 
LVL 1

Expert Comment

by:jazzmoney
ID: 13819860
dondley.com/one and /two
Worked.
dondley.com did not work because of your file source:
<link REL="shortcut icon" HREF="/favicon.ico" type="image/x-icon">

You don't have the file on the root server and/or you didn't specify tmp/favicon.ico as you have on the other pages.

the reason why it may appear then disappear is that it is attempting to show you the cached copy of the icon, then after it looks and doesn't find the file, the icon disappears.
0
 

Author Comment

by:nysus1
ID: 13819942
Sorry, I was probably changing things when you looked at it.  Can you do me a big favor and check dondley.com one more time?  And when you check the /one and /two directories, can you be sure to reload the page?  The icons sometimes work for me there, too, and then they disappear after I reload.  I won't change anything until I hear back from.  And thanks for your time, bro.  I really appreciate this.

Notes:
--Right now, the favicon exists in the /tmp file.
--The index.html file in the root, /one, and /two directories now reads: <link REL="shortcut icon" HREF="/tmp/favicon.ico" type="image/x-icon">

0
 
LVL 1

Accepted Solution

by:
jazzmoney earned 2000 total points
ID: 13820013
It all works perfectly from IE and from FireFox, even when clearing the cache.
0
 

Author Comment

by:nysus1
ID: 13820510
OK, thanks man.  You helped me determine that this is a bug.  I discovered I was still using version 0.9 of Firefox!  I thought I had upgraded this computer to a newer version of Firefox a long time ago.  I'm an idiot.  I just lost a lot of time on that one.  I upgraded and now all is well.

As far as IE goes, you only see the favicon when you save the site as a favorite, right?  Or do I need to upgrade IE, too?
0
 
LVL 1

Expert Comment

by:jazzmoney
ID: 13821296
You don't need to upgrade IE. IE by default does not load the favicon.ico.  IE is very moody.

The other anoying thing is that even after you get it bookmarked and get the icon to display, the icon will disappear after a week or so, depending on when the cache expires.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
The viewer will learn how to count occurrences of each item in an array.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses
Course of the Month16 days, 2 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question