多域名绑同一空间智能跳转的php代码
比如a.com和b.com,都被绑定在一块空间上了,但想要不同的域名指向不同的目录.构想如下:index.php: 重新定向到main.php文件,在main.php文件中判断 来自从index.php中传过来的域名信息,再进行重新定位到目录,开始a.com/index.php或b.com/index.php 都被重新定位到 main.php,根据传过来的到底是a.com 还是b.com 进行分类.
实现代码:
index.php
<?php
Header("Location: main.php");
?>
main.php
<?php
$domain_1="a.com";
$domain_2="b.com";
if(($HTTP_HOST=="$domain_1")or($HTTP_HOST=="www.$domain_1"))
{
Header("Location: a.htm");
}
elseif(($HTTP_HOST=="$domain_2")or($HTTP_HOST=="$domain_2"))
{
include_once('b.htm');
}
else
{
Header("Location: ****.htm");
}
?> :lol N早的...不过也不错..~ 收了~~
:lol :lol :lol :lol 不错的说。;P 有演示么?
页:
[1]