Home  >  Article  >  Backend Development  >  php用header函数实现301跳转代码实例_PHP

php用header函数实现301跳转代码实例_PHP

WBOY
WBOYOriginal
2016-06-01 11:57:39913browse

PHP 301跳转的小代码

复制代码 代码如下:
 $the_host = $_SERVER['HTTP_HOST'];
 $request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
 if($the_host !== 'www.bitsCN.com')
 {
     //echo $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: http://www.bitsCN.com' . $_SERVER['PHP_SELF']  . $request_uri);
 }
?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn