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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:26:15
Original
1194 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:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template