Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

htaccess rule for favicon.ico in subdirectory

Posted on 2009-04-08
4
Medium Priority
?
2,738 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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
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 …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month10 days, 12 hours left to enroll

886 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