PHP Code Implementation 301 Jump Page Instance _php tutorial

Source: Internet
Author: User
301 jump is to tell the visitor page has been forever to the new page, in PHP using 301 jump We use the header () function to send 301 status code to tell the browser, and then implement the page jump.

PHP Pure Code Jump

The code is as follows Copy Code

Header ("location:http://www.bkjia.c0m/");
?>

But this return status code is 302.

If you want to implement 301 jump, you need to set the status code

The code is as follows Copy Code

Header ("http/1.1 301 Moved permanently");
Header ("location:http://www.bkjia.c0m/");
?>


More simple PHP jump 301 Code

The code is as follows Copy Code

$urlto = ' http://www.bKjia.c0m/';
Header (' Location: '. $urlto, TRUE, 301);
?>

Problems that may occur

Warning:cannot Modify header Information-headers already sent by changing the file encoding to UTF-8 no BOM format resolves the problem, and if there is still a problem, check if the string variable is defined before the code. Delete this variable and try again.

Attached: 30* Returns the difference between status codes
301,302 is the encoding of the HTTP state, which means that a URL has been shifted, except that:

1.301 redirect:301 represents a permanent transfer (permanently Moved),
2.302 redirect:302 represents a temporary transfer (temporarily Moved),

What are the benefits or problems when using these two transfers?

301 redirect is the best way to SEO friendly after changing the address of the webpage, as long as it is not temporarily moved, it is recommended to use 301来 to do the forwarding address.

302 redirects are temporary shifts.

http://www.bkjia.com/PHPjc/633121.html www.bkjia.com true http://www.bkjia.com/PHPjc/633121.html techarticle 301 Jump is to tell the visitor page has been forever to the new page, in PHP using 301 jump We use the header () function to send 301 status code to tell the browser, and then implement the page jump ...

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