Page 1 of 1

page custom to url

Posted: Tue Oct 15, 2002 12:19 pm
by foobaa42
say you have two domains pointing to the same index.php page - is it possible to detect which domain the user is loading and display the homepage customized for each domain? examples?

Posted: Tue Oct 15, 2002 2:58 pm
by mr_griff
You should be able to look at the $HTTP_HOST or ($_SERVER["HTTP_HOST"]) variable to determine which url they are coming from.

Code: Select all

<?php
if ($_SERVERї"HTTP_HOST"] == "www.abc.com")
{
   //Display content for abc.com
}
elseif ($_SERVERї"HTTP_HOST"] == "www.xyz.com")
{
  //Display content for xyz.com
}
?>

Posted: Tue Oct 15, 2002 5:23 pm
by foobaa42
thanks - that worked a treat :-)