所有子域子目录中的网站图标
我习惯将 favicon.ico 保存在 public_html
文件夹中以添加 favicon。
我现在遇到的问题是,我想显示某个子目录的所有文件( example.com/example
"onwards" ),只是把它放在那里,似乎并不能完成这项工作。
我知道我可以逐个文档并添加:
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
但我希望有一种更实用的方法,首先我认为可能有一种通过 CSS 的方法,但情况似乎并非如此。
这会派上用场,因为每个文档都已经包含:
<link rel="stylesheet" type="text/css" href="test.css" />
那么有什么想法或解决方法来解决这个问题吗?
I am used to just save the favicon.ico in the public_html
folder for adding the favicon.
The problema I have now is that I want to display the in all the files of a certain subdirectory, ( example.com/example
"onwards" ) just putting it there, doesnt seem to do the job.
I know I could go document by document and add:
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
But I hope there is a more practical way, first I thought there might be a way trough CSS but that doesnt seem to be the case.
This would have come in handy because every document already includes:
<link rel="stylesheet" type="text/css" href="test.css" />
So any ideas or workarounds to how to solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您必须使用
link rel=...
表示法指定网站图标。浏览器将仅在域的根目录中搜索默认的
/favicon.ico
。您必须明确指定的任何变化。You will have to specify the favicon using the
link rel=...
notation.Browsers will search only in the root directory of the domain for a default
/favicon.ico
. Any variations from that you have to specify explicitly.添加
元素是正确的方法。使用模板引擎(例如Template-Toolkit)以避免手动复制常见内容。
Adding the
<link>
element is the right way to go. Use a template engine (e.g. Template-Toolkit) to avoid duplicating common content manually.这可能不是最优雅的方式,我来这里是为了寻找解决方案。
不幸的是,给出的答案不适合我。
就我而言,我在本地主机上工作(通过私有IP),
这就是我所做的:
It might not be the most elegant way, and i came here to find a solution.
Unfortunaly the given answers did not suited for me.
In my case i working on a localhost (via private ip)
this is what i did :
正如上面提到的,不要浪费时间在搜索上。在这种情况下是唯一的方法。当您要检查标记更改的结果时,请记住浏览器缓存可能很棘手。
As mentioned above don't waste time on searching. is the only way in that case. When you will be checking out results of your markup changes, remember that browser cache can be tricky.
将所有子域的 favicon.ico url 重定向到 public_html 的 favicon.ico
即。 subdomain.website.com/favicon.ico 应转到 www.website.com/favicon.ico
redirect favicon.ico url for all subdomains to public_html's favicon.ico
ie. subdomain.website.com/favicon.ico should go to www.website.com/favicon.ico