PHP code implementation 301 jump page instance _ PHP Tutorial

Source: Internet
Author: User
PHP code 301 jump page instance. The 301 jump tells the visitor that the page has always reached a new page. in php, we use the 301 jump function to send the 301 status code to the browser, then, the page jump 301 will tell the visitor that the page has always arrived at a new page. in php, we use the 301 redirect function to send the 301 status code to the browser, then you can jump to the page.

PHP code-only jump

The code is as follows:

Header ("Location: http://www.bKjia. c0m /");
?>

However, the returned status code is 302.

If you want to achieve 301 redirection, you need to set the status code before

The code is as follows:

Header ("HTTP/1.1 301 Moved Permanently ");
Header ("Location: http://www.bKjia. c0m /");
?>


Simpler PHP jump 301 code

The code is as follows:

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

Possible problems

Warning: Cannot modify header information-headers already sent by changing the file encoding to the UTF-8 without BOM format can solve this problem, if there is still a problem, check whether the string variable is defined before the code. delete the variable and try again.

Appendix: differences between 30 * return status codes
301,302 is an HTTP status code, indicating that a URL has been transferred. The difference is:

1.301 redirect: 301 represents permanent transfer (Permanently Moved ),
2.302 redirect: 302 indicates temporary transfer (Temporarily Moved ),

What are the advantages or problems of these two transfer methods?

301 redirection is the best way for seo search engines to be friendly after a webpage address is changed. as long as it is not temporarily moved, we recommend that you use 301 for address conversion.

302 redirection is a temporary transfer.

The Progress () function sends the 301 status code to the browser, and then implements 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.