Implementing HTTP 301 Permanent Redirection _php tutorial with PHP

Source: Internet
Author: User
301,302 is the encoding of the HTTP state, which means that a URL has shifted, except that 301 represents a permanent transfer (permanently Moved) and 302 represents a transient transfer (temporarily Moved).

301 redirect is the best way to search engine friendly after changing the address of the webpage, as long as it is not temporarily moved, it is recommended to use 301来 to do forwarding address, if we put an address using 301 jump way, the search engine will take the old address of PageRank and other information to the new address, At the same time in the Search engine index library to completely discard the original old address.

In PHP, the general implementation of the page jump statement is as follows:

PHP header (' location:http://www.wuwx.cn/');

When we use the tool to view this HTTP header, we find that he returned an HTTP 302 temporary redirect. Instead of the HTTP 301 permanent redirect that we expect, note the first line of fancy:



How should HTTP 301 permanent redirection be implemented? It is also very simple, just add a line of code:

PHP header (' http/1.1 301 Moved permanently ');

Header (' location:http://www.wuwx.cn/');

When we look at the HTTP header of this page again, he returns the HTTP 301 permanent redirect that we expected.

http://www.bkjia.com/PHPjc/364084.html www.bkjia.com true http://www.bkjia.com/PHPjc/364084.html techarticle 301,302 is the HTTP status of the encoding, all means that a URL has been transferred, the difference is that: 301 for permanent transfer (permanently Moved), 302 for temporary transfer (Temporaril ...

  • 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.