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. ...
|
|
|
|