保留二级域名无损跳转方式适用于各类网站,具体使用用途看个人了,我是研究了一会没明白怎么用的。
[lv]
<?php
error_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;
[/lv]

