Home >php教程 >php手册 >php用header函数实现301跳转代码实例

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

WBOY
WBOYOriginal
2016-06-06 20:26:151154browse

分享一个php 301跳转的代码,很简单,主要是用header函数实现转,大家可以参考使用

PHP 301跳转的小代码

复制代码 代码如下:


 $the_host = $_SERVER['HTTP_HOST'];
 $request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
 if($the_host !== 'www.jb51.net')
 {
     //echo $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: ' . $_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