检查当前域

时间:2010-12-03 16:26:48

标签: php dns

我如何知道已打开网站的地址?

我的网站支持一个文件夹上的多个域,我必须提供与域相对应的不同内容。

就像,如果我们在网站http://site.net/

$string = 1;

或者,如果我们在网站http://site.com/

$string = 2;

感谢。

3 个答案:

答案 0 :(得分:4)

答案 1 :(得分:2)

使用$_SERVER['HTTP_HOST']

答案 2 :(得分:1)

if (strstr($_SERVER['SCRIPT_URI'],'site.net'))
{
    $string = 1;
}
if (strstr($_SERVER['SCRIPT_URI'],'site.com'))
{
    $string = 2;
}
相关问题