Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-06 20:26:15
Original
1111 people have browsed it

分享一个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);
 }
?>

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!