Html 无法显示 Favicon.ico

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2201406/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 02:07:06  来源:igfitidea点击:

Cannot get Favicon.ico to display

htmlfavicon

提问by roacha

I have copied my favicon.ico file to my Apache document root. I had to add an Apache Rewrite exception for it and now it is accessible from www.example.com/favicon.ico. But when I hit my main URL it does not show up.

我已将 favicon.ico 文件复制到我的 Apache 文档根目录。我不得不为它添加一个 Apache Rewrite 例外,现在它可以从 www.example.com/favicon.ico 访问。但是当我点击我的主 URL 时,它没有显示出来。

I thought all you had to do was copy the file with the correct permissions into the doc root? Do I need to make php changes? Thanks!

我以为您所要做的就是将具有正确权限的文件复制到文档根目录中?我需要进行 php 更改吗?谢谢!

采纳答案by meme

IE and Firefox can behave differently (not sure which one you are using). Try to add the page as a bookmark, then click the bookmark (to load the page). After you do that exit your browser and see if the if shows up then.

IE 和 Firefox 的行为可能有所不同(不确定您使用的是哪一种)。尝试将页面添加为书签,然后单击书签(以加载页面)。完成后退出浏览器,然后查看 if 是否出现。

If that does not work try to clear your browser cache and repeat the above steps that should fix it. I have seen your problem before!

如果这不起作用,请尝试清除浏览器缓存并重复上述应该修复它的步骤。我以前见过你的问题!

回答by just_wes

Try throwing this tag in the head of your document:

尝试将这个标签扔到文档的头部:

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

回答by Blagovest Buyukliev

Could it be that you uploaded the favicon after your browser has remembered that your domain doesn't have one and therefore doesn't issue a new request?

可能是您在浏览器记住您的域没有一个 favicon 后上传了 favicon,因此不会发出新请求?

回答by Milap

favicon icon behaves differently for different browswrs & sometimes if it works in FF & does not work in IE. Try after Clearing the cache of the browser and standard code for favicon ico is, Just put below tag in your index file OR whichever common file for your project.

favicon 图标对于不同的浏览器有不同的表现,有时如果它在 FF 中工作并且在 IE 中不起作用。在清除浏览器的缓存后尝试 favicon ico 的标准代码是,只需将下面的标签放在您的索引文件或您项目的任何公共文件中。

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

Although new browsers support GIF and PNG images , but , I would suggest always saving the image as favicon.ico.

虽然新的浏览器支持 GIF 和 PNG 图像,但是,我建议始终将图像保存为 favicon.ico。

回答by jobeard

the favicon.ico reference must be an absolute URL, not relative. Using this:

favicon.ico 引用必须是绝对 URL,而不是相对 URL。使用这个:

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

My status was

我的状态是

favicon.ico () shows up in:

    IE 9.0.8
    Safari 5.1.7 

Fails in:

    FF 28.0
    Google Chrome 34.0

changing to absolute values

变为绝对值

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

causes all browsers to locate and display the favicon.ico

导致所有浏览器定位并显示 favicon.ico

回答by 4424dev

It seems like in Chrome that you cannot use a link (ex. https://) rather must you have the favicon.icoin the same folder as the index.html. For any other file, it seems to work with a link.

似乎在 Chrome 中您不能使用链接(例如https://),而必须favicon.icoindex.html. 对于任何其他文件,它似乎可以使用链接。

回答by corymathews

Some browsers will pick up the icon if its in the root directory without adding anything to the page, however IE and FF don't. Add this code to the head section of your page

一些浏览器会选择根目录下的图标而不向页面添加任何内容,但是 IE 和 FF 不会。将此代码添加到页面的头部部分

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

回答by Paul Sasik

Try placing the ico file in an images folder in your root. That's where many browsers look for favicon. And that's something to keep in mind. Favicon is a very loose standard, if you can even call it that, which is supported by browsers, not by the server. The browsers themselves actually fetch favicons in separate calls to display on their favorites bars, or tabs... The favicon file just has to be placed somewhere that the browsers can find it.

尝试将 ico 文件放在根目录下的图像文件夹中。这就是许多浏览器寻找网站图标的地方。这是需要牢记的。Favicon 是一个非常松散的标准,如果你甚至可以称之为它,浏览器支持,而不是服务器支持。浏览器本身实际上在单独的调用中获取网站图标以显示在他们的收藏夹栏或选项卡上......只需将网站图标文件放置在浏览器可以找到它的地方。