php用header函数实现301跳转代码实例_PHP
程序员文章站
2022-04-04 10:50:02
...
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);
}
?>