This article introduces how to solve the php header 404 error file garbled. If you encounter such problems, refer.
Usually, when judging a non-existing resource (such as category or product does not exist) through php, you need to return a 404 status through the header and display the corresponding 404 page. The method on the previous server is as follows:
The Code is as follows: |
Copy code |
Header ('HTTP/1.1 404 Not Found '); Header ('status: 404 Not Found '); Require ('2014. php '); Exit (); |
However, after a new server is changed, it finds that some letters and numbers are garbled on the page. After checking, it is found that the communication protocol version is inconsistent with HTTP/1.1 in the code when the current server request page is displayed, to know the name and version of the communication PROTOCOL of the current server, use $ _ SERVER ['server _ Protocol']. After testing, the http version of my SERVER is 1.0, so the code should be changed:
The Code is as follows: |
Copy code |
Header ('HTTP/1.0 404 Not Found '); Header ('status: 404 Not Found '); Require ('error. php '); Exit (); |