我网站中所有页面的网站图标
我了解到为网页添加网站图标的方法是在页面中添加以下几行。
<link rel="SHORTCUT ICON" type="image/x-icon" href="http://mysite.com/faviconfilename.ico"/>
<link rel="icon" type="image/x-icon" href="http://mysite.com/faviconfilename.ico" />
我应该在我网站的每个页面中添加此代码吗?我使用 Apache - tomcat 集群来提供页面服务。还有其他简单的方法可以做到这一点吗?
I've learned that the way to add favicon for a web page is to have the following lines in the page.
<link rel="SHORTCUT ICON" type="image/x-icon" href="http://mysite.com/faviconfilename.ico"/>
<link rel="icon" type="image/x-icon" href="http://mysite.com/faviconfilename.ico" />
Should i add this code in each and every page my site has?? I use Apache - tomcat clustering to serve pages. Is there any other easy way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是我的 php 网站的方法。它确保如果您更新网站图标,当您的客户访问您的网站时,它将立即更新:
Here is my method for php sites. It ensures that if you update the favicon, it will be updated immediatly when your clients visit your site:
通常将一个名为“favicon.ico”的文件放在网站的根目录中就足够了。
It is usually enough to place a file called "favicon.ico" in the root of your website.
您可以使用以下 Apache 配置咒语来消除不必要的处理和流量以及错误日志条目:
You can get rid of the unnecessary processing and traffic as well as the error log entries by using the following Apache configuration incantations:
修改apache配置。
将此文件上传到您网站的根目录。确保它是可读的,以便 apache 可以读取它。如果您有 shell 访问权限,请输入:“chmod +r favicon.ico”。
然后编辑 httpd.conf 并插入以下行:
"AddType image/x-icon .ico"
当您无权访问 apache 配置时,您的方法有效。在这种情况下,如果您正在使用任何框架,那么您应该将其添加到您的布局/模板中。
Modify the apache config.
upload this file to the root directory of your website. Make sure that it is readable so that apache can read it. If you have shell access, type: "chmod +r favicon.ico".
Then edit httpd.conf and insert the following line:
"AddType image/x-icon .ico"
Your approach works when you don't have access to your apache config. In this case, if you are using any framework then you should add it to your layout/template.