Home  >  Article  >  Backend Development  >  PHP 301 Redirect Implementation of Permanent Redirect_PHP Tutorial

PHP 301 Redirect Implementation of Permanent Redirect_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 14:54:551059browse

Commonly used redirect methods are: 301 redirect, 302 redirect and meta fresh:

301 redirect: 301 stands for Permanently Moved. 301 redirect is the best way to be search engine friendly after the web page changes its address. As long as it is not a temporary move, it is recommended to use 301 for redirection.

302 redirect: 302 stands for Temporarily Moved. In the past few years, many Black Hat SEOs have widely used this technology to cheat. At present, all major search engines have stepped up their crackdowns, such as Google. The penalties imposed on Business.com in recent years and more recently on BMW Germany's website. Even if a website is not spam objectively, it can easily be misjudged as spam by search engines and punished.
meta fresh: This was more popular before 2000, but is now rare. Specifically, it uses the meta instruction in the web page to redirect to a new web page after a specific time. If the delay time is too short (within about 5 seconds), it will be judged as spam.

Here we mainly talk about how to redirect web pages through 301 Redirect.

Copy to ClipboardLiehuo.Net CodesQuoted content: [www.bkjia.com] $the_host = $_SERVER['HTTP_HOST'];//Get the current domain name
$request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';//Determine whether the address is followed by There are parameters
if($the_host == 'seocity.cn')//Replace the domain name here with the one you want
{
Header('HTTP/1.1 301 Moved Permanently');// Issue a 301 header
Header('Location: http://www.seocity.cn.$request_uri);//Jump to the address format you want
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/364475.htmlTechArticleCommonly used redirect methods are: 301 redirect, 302 redirect and meta fresh: 301 redirect: 301 represents permanent transfer (Permanently Moved), 301 redirect is a search redirect after the web page changes its address...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn