Two domains, one site, different pages served

I am currently working on a complex website that requires two different companies on two different domains to share the same website. I have just mananged to create a piece of php code to analyse the domain name typed in and redirect to the correct section of the site for that company. Awesome!

$url = $_SERVER['HTTP_HOST'];
if(strpos( strtolower($url), "site2" )!=FALSE) {
header('location:site2/index.php');
} else {
header('location:site1/index.php');
}

It is not often that code makes me happy.

Comments are closed.