保留二级域名无损跳转方式-博客程序技术分享中心-开发交流社区-GOdou社区

保留二级域名无损跳转方式

<?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;
请登录后发表评论

    没有回复内容