网站图标未显示,.htaccess 惹的祸?
我在让网站图标适用于我的网站时遇到问题。
我有两个域指向一个托管帐户,一个指向根目录,另一个(我在这里讨论的那个)指向根目录上的文件夹。
它们都有 .htaccess 文件来处理 404 请求、缩短 url 并重定向 favicon 请求。我使用 .htaccess 文件是因为这对我来说相对容易(我没有时间将其更改为其他文件)。
但是这个网站(位于根目录下的文件夹中)不会显示图标。一切都已就位。但当我继续操作时,它只是不显示图标。
这是 html 的部分:
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
这是 .htaccess 文件:
ErrorDocument 404 /404.php
RewriteEngine On
RewriteCond %{HTTP_HOST} !^getfilm.co.uk$ [NC]
RewriteRule ^(.*)$ http://getfilm.co.uk/$1 [L,R=301]
<ifmodule mod_rewrite.c>
RewriteCond %{REQUEST_URI} !^/favicon\.ico [NC]
RewriteCond %{REQUEST_URI} favicon\.ico [NC]
RewriteRule (.*) http://getfilm.co.uk/favicon.ico [R=301,L]
</ifmodule>
I'm having problems getting a favicon to work for my website.
I've got two domains pointing to one hosting account, one points to the root and the other (the one I'm talking about here) to a folder on the root.
They both have .htaccess files to deal with 404 requests, shortening the url and redirecting favicon requests. I'm using .htaccess files because it's relatively easy to do for me (I don't have the time to be changing it to something else).
But this website, the one in a folder on the root, won't show the favicon. Everything is in place as it should be. But it just doesn't show a favicon when I go on to it.
Here's the bit of html:
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
Here is the .htaccess file:
ErrorDocument 404 /404.php
RewriteEngine On
RewriteCond %{HTTP_HOST} !^getfilm.co.uk$ [NC]
RewriteRule ^(.*)$ http://getfilm.co.uk/$1 [L,R=301]
<ifmodule mod_rewrite.c>
RewriteCond %{REQUEST_URI} !^/favicon\.ico [NC]
RewriteCond %{REQUEST_URI} favicon\.ico [NC]
RewriteRule (.*) http://getfilm.co.uk/favicon.ico [R=301,L]
</ifmodule>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您写 href="favicon.ico" 则意味着您的图标位于页面旁边。如果您的页面位于其他文件夹中,您需要寻址folder/icon.ico
if you write href="favicon.ico" it means, your icon is located beside your page. if your page is in other folder you need to address the folder/icon.ico