Solved

htaccess rule for favicon.ico in subdirectory

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now