page custom to url

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
foobaa42
Forum Newbie
Posts: 2
Joined: Tue Oct 15, 2002 12:19 pm

page custom to url

Post 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?
User avatar
mr_griff
Forum Commoner
Posts: 64
Joined: Tue Sep 17, 2002 11:11 am
Location: Bozeman, Montana

Post 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
}
?>
foobaa42
Forum Newbie
Posts: 2
Joined: Tue Oct 15, 2002 12:19 pm

Post by foobaa42 »

thanks - that worked a treat :-)
Post Reply