Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

htaccess rule for favicon.ico in subdirectory

Posted on 2009-04-08
4
2,698 Views
Last Modified: 2012-06-27
Hello,

I'm looking for an htaccess rule for adding unique favicons to a subdirectory. I have many subdirectories on a primary domain name:

www.domain.com/this1
www.domain.com/this2
www.domain.com/this3
www.domain.com/this4

etc..

I would like each subdirectory (recursively) to have it's own favicon without editing the HTML.

ie:

www.domain.com/this1 // gets the favicon: /icons/this1.ico
www.domain.com/this2 // gets the favicon: /icons/this2.ico
www.domain.com/this3 // gets the favicon: /icons/this3.ico
www.domain.com/this4 // gets the favicon: /icons/this4.ico

 I'm not good with htaccess rules, but I'm pretty sure this is possible. Thanks for any help!
0
Comment
Question by:Mahdii7
  • 2
  • 2
4 Comments
 
LVL 27

Expert Comment

by:caterham_www
ID: 24110781
Do you use cookies to store the state if someone requests a subdir or not? Otherwise, since http is a stateless protocol, how would you know if a client requests /favicon.ico that there was a previous request for /this1/?
0
 
LVL 9

Author Comment

by:Mahdii7
ID: 24153011
Sorry for the late reply.

I don't think I make myself clear. I'm looking for this (no idea how to code htaccess) on REHL/Apache:

Thanks!!
domain.com/this1/.htaccess // subdir .htaccess
 // Contents
 rewrite URL if it's domain.com/favicon.ico
 change to domain.com/this1/favicon.ico
 // this1 is static, that's fine. this1 also contains hundreds of pages I don't want to add meta tags with favicon info to
 
domain.com/.htaccess // root dir htaccess
 // contents
 (blank, just grab default favicon)

Open in new window

0
 
LVL 27

Accepted Solution

by:
caterham_www earned 500 total points
ID: 24154997
Again, HTTP is a stateless protocol, your concept can't work. The request of the html page and its embedded resources or other resources such as a favicon are different, completely separate requests.

BTW: domain.com/this1/.htaccess isn't read at all, if domain.com/favicon.ico was requested since the request has no connections to the subdirectory.
0
 
LVL 9

Author Closing Comment

by:Mahdii7
ID: 31571094
Thanks. Too bad, but I understand.

I know that domain/favicon.ico is the only accepted request, I just was hoping there was a way to bypass writing in meta tags for favicon placement in my documents. Oh well.
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

839 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