保留二级域名无损跳转方式
<?phperror_reporting(0);
$domain = 'baidu.com';//需要跳转的域名
$host = $_SERVER['HTTP_HOST'];
$dot1 = strpos($host,'.');
$dot2 = strrpos($host,'.');
if($dot1==$dot2){//一级域名
header("Location: http://{$domain}");
}else{//二级域名
$attr = substr($host,0,$dot1);
$location = $attr.'.'.$domain;
header("Location: http://{$location}/");
}
exit;
页:
[1]