开发者

Automatic favicon on sub-directories and files

开发者 https://www.devze.com 2023-03-07 07:58 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消