James
James

Reputation: 43677

Check current domain

How do I know address of opened site?

My site supports multiple domains on one folder, I have to give a different content corresponding to domain.

Like, if we are on site http://site.net/:

$string = 1;

Or, if we are on site http://site.com/:

$string = 2;

Thanks.

Upvotes: 2

Views: 794

Answers (3)

Svisstack
Svisstack

Reputation: 16656

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

Upvotes: 1

casablanca
casablanca

Reputation: 70721

Use $_SERVER['HTTP_HOST'].

Upvotes: 2

Related Questions