php用header函数实现301跳转代码实例
(编辑:jimmy 日期: 2024/11/19 浏览:3 次 )
PHP 301跳转的小代码
复制代码 代码如下:
<?php
$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: https://www.jb51.net' . $_SERVER['PHP_SELF'] . $request_uri);
}
?>
下一篇:保存到桌面、设为桌面且带图标的PHP代码