This article will introduce to you the solution to the php header 404 error containing garbled files. Students who have encountered such problems can refer to it for reference.
Usually when you use PHP to determine a non-existent resource (such as category or product does not exist), you need to return a 404 status through the header and display the corresponding 404 page. On the previous server, it was written as follows:
The code is as follows
代码如下 |
复制代码 |
header('HTTP/1.1 404 Not Found');
header('Status: 404 Not Found');
require('404.php');
exit();
|
|
Copy code
|
header('HTTP/1.1 404 Not Found');
代码如下 |
复制代码 |
header('HTTP/1.0 404 Not Found');
header('Status: 404 Not Found');
require('error.php');
exit();
|
| header('Status: 404 Not Found');
require('404.php');
exit();
However, after switching to a new server, I found that there were some garbled letters and numbers on the page. After checking, I found that the version of the communication protocol when requesting the page of the current server was inconsistent with the HTTP/1.1 in the code. If you want to know the name of the communication protocol of the current server and The version can be $_SERVER['SERVER_PROTOCOL']. After testing, the http version of my server is 1.0, so the code needs to be modified to:
The code is as follows
|
Copy code
header('HTTP/1.0 404 Not Found');
header('Status: 404 Not Found');
require('error.php');
http://www.bkjia.com/PHPjc/632099.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632099.htmlTechArticleThis article will introduce to you the solution to the php header 404 error containing garbled files. Anyone who has encountered such a problem Students can enter for reference. Usually when judging a non-existent one through php...
|
|