您的位置:首页 > 编程语言 > PHP开发

php301跳转

2016-01-28 14:25 459 查看
<?php
$the_host = $_SERVER['HTTP_HOST'];//取得当前域名
$the_url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';//判断地址后面部分
$the_url = strtolower($the_url);//将英文字母转成小写

if($the_url=="/index.php")//判断是不是首页
{
$the_url="";//如果是首页,赋值为空
}
if($the_host == 'www.baidu.com')
{
header('HTTP/1.1 301 Moved Permanently');//发出301头部
header('Location:http://www.taobao.com'.$the_url);//跳转到带www的网址
}

?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: