Automatic favicon on sub-directories and files
My friend recently provided me with some disk space on his VPS and gave me the use of http://IP/czdavid/
. I am not currently in need of a domain name since it will serve me as a file sharing site.
Now, the problem is that he has his favicon on the root of the IP and browsers search for it there. I can resolve the problem on individual pages with <link rel="shortcut icon" type="image/x-icon" href="favicon.ico"/>
, the problem is that directo开发者_Python百科ry listing and actual files - images and text files and other opened in a browser - will show the domain favicon.
Is there any way to set a favicon for the entire sub-directory, short of getting a domain name?
No, this is not possible.
favicon.ico
will be retrieved from the root of the site, unless specified in a link
element on an HTML page.
The only way I can think of, would be to use the URL rewriting capabilities of the web server. At least in case of an apache, it would be possible to create a ruleset, that would deliver a different favicon depending on the referrer from the request.
But it is an ugly hack and only works, if browsers actually submit a referrer with a request for a favicon.
精彩评论