Considerations for 301/404 redirection in php header

Source: Internet
Author: User

301 jump

The code is as follows: Copy code

Header ('http/1.1 301 Moved Permanently ');
Header ('Location: http://www.abc.com/aaa /');
Exit ();

Do not miss the header ('http/1.1 301 Moved Permanently '); otherwise, no 301 is returned.

404 error page

The code is as follows: Copy code

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

If the above does not work, try the following:

The code is as follows: Copy code

Header ("Status: 404 Not Found ");

So to be foolproof, you can write either of the following two 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 the webmaster tool to test whether the returned status is what we want.

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.