Simple Talk about favicon_php skills

Source: Internet
Author: User

Favicon.ico Introduction

What is Favicon.ico, perhaps too much to be accustomed to (I am, until this article was written before I know), to see the Wikipedia explanation:

Copy Code code as follows:

Favicon is the abbreviation of Favorites icon, also known as website icon (Web page icons), page icon (page icons) or Urlicon (URL icon), the following is a link Http://zh.wikipedia.org/wiki/Favicon

In fact, this is the thing, most of the Web site will be open in the browser tab leftmost display this small icon, this is Favicon.ico

How to set this icon, how many students like me to this small detail accustomed to, but do not know how to set up a hand (here under review, there are a lot of details of the face can be bruised, but I do not really know him, more frightening is my subconscious think I know him ... )。

Favicon Settings

How to set this, set the method is very simple, there are two ways:

The default is placed under the server root directory

is to name the file Favicon.ico and placed in the root directory of the site can be, the browser will automatically request to obtain http://host/ Favicon.ico, this request in the browser through the F12 is not visible, need to use other tools (such as fiddler) to see, or open the server access log, such as my this, nginx log will display the Web page icon request
"13/may/2015:16:07:31 +0800" "192.168.x.x" "test.test.com" "," "Get/favicon.ico http/1.1" "4409" ...

Modify the location and name of the page icon through the link tag

This approach is to use the HTML link tag to set the location and name of the page chart, just like the following
<link href= "Favicon_baoman.ico" type= "Image/x-icon" rel= "icon" >

Pay attention.

Browser will cache icon information, Firefox I tried it is every once in a while (2 minutes or so) will request a favicon,chrome to delete data can be requested again ~ ~

What's the impact?

This problem is found because the PHP framework, the PHP framework through PathInfo to resolve the route, the route is "Mod/controller.method", if not matching the log and return 404, I access a correct path will also be reported that the route does not exist, But the interface return is OK, access to a wrong route will log two error logs, this is what is going on, the following is my Nginx configuration

 server {
   listen  ;
   server_name test.test.com;

   Location/{
     root/export/adsz/boss/php/sphp;
     Fastcgi_pass  127.0.0.1:9000;
     Fastcgi_index  index.php;
     Fastcgi_split_path_info ^ (? U). +\.php) (/?. +)$;
     Fastcgi_param script_filename $document _root$fastcgi_script_name;
     Fastcgi_param path_info $fastcgi _path_info;
     Include Fastcgi_params;
     Rewrite ^/(. *) $  /index.php/$1 break;
   }
 

Nginx configuration causes this problem to exist, when the browser requests an interface, it will default to bring the http://test.test.com/ Favicon.ico, this time the way out is wrong to think of the pass, the browser issues two requests, one that makes us want, and the other is the ICO Web icon request, and the solution is simple enough to add the diagram to the configuration or locate the Favicon request elsewhere:

 server {
   listen  ;
   server_name test.test.com;
  Location =/favicon.ico {
    root/wwroot/public/images/;
  }
   Location/{
     root/wwroot/;
     Fastcgi_pass  127.0.0.1:9000;
     Fastcgi_index  index.php;
     Fastcgi_split_path_info ^ (? U). +\.php) (/?. +)$;
     Fastcgi_param script_filename $document _root$fastcgi_script_name;
     Fastcgi_param path_info $fastcgi _path_info;
     Include Fastcgi_params;
     Rewrite ^/(. *) $  /index.php/$1 break;
   }
 

Summarize

Find this reason and modify, I looked carefully at the Nginx configuration, found that other virtual hosts have to configure this favicon.ico matching rules! I'm so embarrassed. , summed up, is to see more, think more why, do not lose interest in a lot of things, not to be surprised

The above mentioned is the entire content of this article, I hope you can enjoy.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.