Precautions for 301/404 redirection in phpheader _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
In phpheader, pay attention to the 301404 redirection. If your webpage shows 301 or 404, it is a very serious problem for the user experience, so we must be careful when doing phpheader301 or 404. let's take a look at it. If your webpage shows 301 or 404, it is a very serious problem for the user experience, so we must be 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 ();

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

404 error page

The code is as follows:

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

If the above does not work, try the following:

The code is as follows:

Header ("Status: 404 Not Found ");

So to be foolproof, you can write either of the following two sentences:

The code is as follows:

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.

When checking header301 or 404, you must be careful and take a look at it ....

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.