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