Solved

htaccess rule for favicon.ico in subdirectory

Posted on 2009-04-08
4
2,716 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
[X]
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
  • 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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

734 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