Home > Backend Development > PHP Tutorial > Detailed explanation of matters needing attention in 301/404 jump in PHP header_PHP Tutorial

Detailed explanation of matters needing attention in 301/404 jump in PHP header_PHP Tutorial

WBOY
Release: 2016-07-13 10:44:17
Original
917 people have browsed it

If 301 or 404 appears on your webpage, it is a very serious problem for the user experience, so we must be more careful when doing php header301 or 404. Let me take a look.

301 jump

The code is as follows
 代码如下 复制代码

header('HTTP/1.1 301 Moved Permanently');  
header('Location: http://www.abc.com/aaa/');  
exit();

Copy code

header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.abc.com/aaa/');
exit();

 代码如下 复制代码

header("HTTP/1.1 404 Not Found");

Don’t miss the header(‘HTTP/1.1 301 Moved Permanently’); otherwise 301 will not be returned

 代码如下 复制代码

header("Status: 404 Not Found");

404 error page

 代码如下 复制代码

header("HTTP/1.1 404 Not Found");
header("Status: 404 Not Found");

The code is as follows

Copy code

header("HTTP/1.1 404 Not Found");

If the above doesn’t work, you can try the following:

The code is as follows Copy code
header("Status: 404 Not Found"); So to be sure, you can write both sentences:
The code is as follows Copy code
header("HTTP/1.1 404 Not Found");
header("Status: 404 Not Found");
Tips, After writing the code, we must use webmaster tools to test whether the returned status is what we want. http://www.bkjia.com/PHPjc/633119.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/633119.htmlTechArticleIf 301 or 404 appears on your webpage, it is a very serious problem for the user experience, so we You must be more careful when doing php header301 or 404. Let me take a look. ...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template