Solved

htaccess rule for favicon.ico in subdirectory

Posted on 2009-04-08
4
2,689 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP Curl Multi-exec 13 71
How to analyze web traffic logs 10 107
Xampp Not Stopping 9 41
Internal Server Error on 1&1 Apache Server running PERL 3 15
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

785 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