eszyttvi

PHP achieve the 301 permanent and 302 temporary redirect redirect

PHP:

)

/ / URL

Header (" Location:; 贵族宝贝hzhuti贵族宝贝/"

?

redirect principle is very simple, is a HTTP header Web server to send HTTP header PHP visit the visitor, this function is provided by the header () function to achieve. 301, 302, 404 these status codes are stipulated in HTTP agreement, so don’t break the casserole to ask "why is 301 instead of 3001". Pull many, back to the topic.

>

header (" $http_protocol 301; Moved Permanently"

/ / 301

to PHP 404 error also comes with:

PHP:

301 redirect

exit (

)

code

redirection specified ?

$http_protocol = $_SERVER[‘SERVER_PROTOCOL’]; //http protocol version

(" Location:$new_url" header;

code

$http_protocol =’HTTP/1.0′;

header (‘HTTP/1.1 301 Moved Permanently’

);

) 302 redirect

header (" Location:; 贵族宝贝hzhuti贵族宝贝/"

//301 permanent redirect

!) response status code

or

code

$new_url =’贵族宝贝111cn.net/’;

/ / if it is other agreement, the default is HTTP/1.0

);

if (‘HTTP/1.1′! = $http_protocol & &’HTTP/1.0’ = $http_protocol

exit (

) );

< php