php301跳转代码

判断是否为某个域名后跳转 

$yuming = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '');//获取当前域名
$the_url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
if($yuming !== 'www.shiguan6.com')//如果域名不是带www的网址那么进行下面的301跳转
{
header('HTTP/1.1 301 Moved Permanently');//发出301头部
header('Location:http://www.shiguan6.com'.$the_url);//跳转到带www的网址
}

  

 直接跳转

Header("HTTP/1.1 301 Moved Permanently");
Header("Location: http://www.shiguan6.com");

  

上一篇:LeetCode刷题301.删除无效括号


下一篇:Leetcode刷题java之301删除无效括号