2010-12-03 85 views
2

我如何知道打开网站的地址?查看当前域名

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

一样,如果我们都在现场http://site.net/

$string = 1; 

或者,如果我们都在现场http://site.com/

$string = 2; 

感谢。

回答

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