function go301($website)
{
$the_host = $_SERVER['HTTP_HOST']; //获取主域名
// var_dump($the_host);
//"www.yzwlzy.com"
$request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; //获取后缀
if ($the_host != $website) {
header('HTTP/1.1 301 Moved Permanently');
header('Location: https://' . $website . $request_uri);
die();
}
}

本来是想高级点用.htaccess重定向的。。结果老是不成功也不找原因了。。就这样用php重定向吧