我有一个网站图标.ico链接到我的网站。
<link rel="shortcut icon" href="http://nameofsite.com/favicon.ico" type="image/x-icon" />
但是,您会注意到,当您访问时,您会收到错误消息:
无法显示图像"链接到图像",因为它包含错误。
我尝试将favicon.ico文件上传到另一台服务器,它加载没有任何问题。这让我相信也许我的htaccess文件正在影响它?
在我的htaccess文件中,我确保添加规则来排除任何处理"ico"扩展名的内容,以便可以查看ico文件。一些规则包括:
# SITE NAVIGATION
# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !.(css|gif|jpg|jpeg|png|ico|txt|xml|js|pdf|html)$ /root/to/public_html/nameofsite.com/index.php [NC,L]
# ANTI-HOTLINKING
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?nameofsite.com(/)?.*$ [NC]
RewriteRule .*.(gif|jpg|jpeg|bmp|png|ico|css|js|pdf)$ http://nameofsite.com [R,NC]
但是,我找不到这些规则的任何错误。欢迎任何建议,我有点不知所措。
尝试重新上传您的 favicon.ico 文件,它是空的:
$ curl -i http://thejadednetwork.com/favicon.ico
HTTP/1.1 200 OK
Date: Thu, 19 Dec 2013 10:15:00 GMT
Server: Apache
Last-Modified: Mon, 24 Sep 2012 01:13:21 GMT
Accept-Ranges: bytes
Content-Length: 0
Content-Type: image/x-icon
另一个建议,这个规则:
RewriteCond %{HTTP_REFERER} !^http://(www.)?nameofsite.com(/)?.*$ [NC]
也会匹配http://nameofsite-com.example.com/
.你可能的意思是:
RewriteCond %{HTTP_REFERER} !^http://(www.)?nameofsite.com(/|$) [NC]