Favicon for all the pages in my website

南楼画角 提交于 2019-12-09 14:19:38

问题


I've learned that the way to add favicon for a web page is to have the following lines in the page.

<link rel="SHORTCUT ICON" type="image/x-icon" href="http://mysite.com/faviconfilename.ico"/>
<link rel="icon" type="image/x-icon" href="http://mysite.com/faviconfilename.ico" />

Should i add this code in each and every page my site has?? I use Apache - tomcat clustering to serve pages. Is there any other easy way to do this?


回答1:


It is usually enough to place a file called "favicon.ico" in the root of your website.




回答2:


You can get rid of the unnecessary processing and traffic as well as the error log entries by using the following Apache configuration incantations:

# Don't bother looking for favicon.ico
Redirect 404 /favicon.ico

# Send custom text instead of sending the custom error page
<Location /favicon.ico>
    ErrorDocument 404 "No favicon"
</Location>



回答3:


Modify the apache config.

upload this file to the root directory of your website. For some reason the execute bit has to be set on this file for apache to use it. If you have shell access, type: "chmod +rx favicon.ico".

Then edit httpd.conf and insert the following line:

"AddType image/x-icon .ico"

Your approach works when you don't have access to your apache config. In this case, if you are using any framework then you should add it to your layout/template.




回答4:


Here is my method for php sites. It ensures that if you update the favicon, it will be updated immediatly when your clients visit your site:

<link rel="shortcut icon" href="favicon.ico?v=<?php echo time() ?>" />


来源:https://stackoverflow.com/questions/2729401/favicon-for-all-the-pages-in-my-website

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!