2011-12-12 60 views
0

我有一个favicon文件,不会显示在我的网站上。 起初我以为这可能是责怪htaccess,但我不确定这是否是正确的方向。Favicon没有显示,即使在检查直接URL到favicon文件

我的htaccess被设置为发送该URL的index.php解析:

#Pass to index.php 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule !\.(css|gif|jpe?g|png|txt|xml|js|pdf|html)$ /home/username/public_html/domain.com/index.php [NC,L] 

#Hotlinking 
RewriteCond %{HTTP_REFERER} !^$ 
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain.com(/)?.*$ [NC] 
RewriteRule .*\.(gif|jpe?g|bmp|png|ico|css|js|pdf)$ http://domain.com [R,NC] 

而且我有以下HTML:

<link rel="icon" href="http://domain.com/favicon.ico" /> 
<link rel="shortcut icon" href="http://domain.com/favicon.ico" /> 

当我尝试访问该文件的favicon.ico直接,图像根本不加载。当我尝试在本地打开图像文件时(从我的硬盘,使用chrome或firefox)它打开并显示正常。

+1

返回的图标有零字节。上传时,我认为出现了问题。没有看到htaccess会如何造成这种情况。但你可以尝试暂时删除所有的htaccess,看看问题是否存在。 – Gerben

+0

@Gerben我试着纠正你的笔记 - 重新上传了favicon文件,同时也删除了htaccess文件,但没有任何改变。 – Jay

+1

你的ftp客户端为这个文件提供什么文件大小。尝试将它重命名为'icon.ico'或者甚至是'icon.txt'等其他东西,然后查看是否在浏览器中输出了某些内容(也可以尝试不使用htaccess)。 – Gerben

回答

0

请参阅上面的解决方案/解决方法的注释。