简体   繁体   English

我无法显示favicon.ico

[英]Cannot my get favicon.ico to display

I have saved the favicon.ico in the root folder and added the following code to the head section of my home page. 我已经将favicon.ico保存在根文件夹中,并将以下代码添加到主页的开头部分。 I've tried clearing my cache and also bookmarking the page then reloading it. 我尝试清除缓存,也将页面添加为书签,然后重新加载。 The icon still does not display. 该图标仍然不显示。

<link rel="shortcut icon" href="/favicon.ico" >
<link rel="icon" href="/favicon.ico" >

Any suggestions? 有什么建议么?

Ensure you're serving it with the correct MIME type; 确保使用正确的MIME类型为其提供服务; see Paul Irish's comments . 请参阅Paul Irish的评论

The gist of it is that while some say that the standard MIME type is image/vnd.microsoft.icon, IE can only display it when its served with a MIME type of image/x-icon. 要点是,尽管有人说标准MIME类型是image / vnd.microsoft.icon,但IE仅在以MIME类型为image / x-icon时才可以显示它。

First, examine the headers (using Firebug, Chrome Inspector Tools, IE Developer Tools and whatever Safari uses.) for the HTTP request for favicon.ico. 首先,检查用于favicon.ico的HTTP请求的标头(使用Firebug,Chrome Inspector工具,IE开发人员工具以及Safari使用的任何工具。)。 Check for MIME, and see what it says. 检查MIME,并查看其内容。 If its wrong, add this to your .htaccess: 如果错误,请将其添加到您的.htaccess中:

AddType image/x-icon ico

If MIME type isn't the problem, see this excellent answer by mercator; 如果MIME类型不是问题,请查看墨卡托的出色答案 you don't actually have to add the <link> tag for it since Browsers automatically request /favicon.ico, unless you 您实际上不必为此添加<link>标记,因为浏览器会自动请求/favicon.ico,除非您

  • Make it a .png, 设为.png
  • Locate it somewhere other than the web root, 将其定位在网络根目录之外的其他位置,
  • Or really, really want to name the icon as something other than favicon.ico. 或真的,真的想将图标命名为favicon.ico以外的名称。

It shoud be 应该是

<link rel="shortcut icon" href="/favicon.ico" />
<link rel="icon" href="/favicon.ico" />

you forget both /> close tags 您会忘记两个/>关闭标签

Edited try this: 编辑试试这个:

<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM