Article reprinted from PHP using header+location to achieve website 301 Redirect | Lanzhou Fly Rain seo | Http://www.feiyuseo.com/seo-jishu/145.html
For our SEO staff, sometimes need to redirect the site. In general, HTTP return status codes for site redirection are 301 and 3,022. We'll show you how to use Header+location to implement web 301 redirection via PHP using an example.
About the problem of the orientation of the PHP website, in Baidu search above the noon, found that the most used is the use of "header+location" redirection method. Below I give the most popular code:
<? Phpheader ("location:http://www.feiyuseo.com"); exit; >
But through my query to the HTTP status code found that the above code to jump redirected after the return code is 302 state. Let's take a look at what is a 302 return code? The search engine returned a 302 error indicating that the requested resource was temporarily transferred (Moved temporatily), and then a transferred URL was given, and the browser, when processing the 302 error returned by the server, would in principle reestablish a TCP connection and then fetch the redirected URL page But if the page exists in the cache, it is not retrieved. However, due to black hat SEO abuse 302 Redirect to cheat, 302 redirects have been regarded as spam information, by the major search engine hit. Therefore, the above code returns 302 status is not perfect, but also exists by Baidu and other search engine K station risk.
Look at the second method: return the 301 status code before redirecting.
<? Phpheader (' http/1.1 301 Moved permanently '); Header ("location:http://www.feiyuseo.com"); exit; >
This section of the code above can be said to solve the problem of using location to generate 302 State, it is a more complete and relatively safe site redirection method. Just in preparation for the time, I suddenly found a jump code, is also very good, more streamlined than this, here I also attached to everyone, share.
<? Phpheader ("location:http://www.feiyuseo.com", true,301);); exit; >
This line of code on the implementation of the 301 redirection of the site, and efficient, safe, reliable operation.
The above describes PHP using Header+location to achieve site 301 redirection, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.