Php header 404 error inclusion file garbled Solution

Source: Internet
Author: User

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 ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.