...

View Full Version : Getting Location Address



jeremywatco
03-22-2004, 03:35 PM
I am looking for a way to grab the location address in PHP. I am used to doing it in javascript with an easy:

if (location="blah.com")
{
do stuff
}

however I need a way to do this with PHP because our website has 6 different domain names pointed to it and I would like to display certain values based on the address they type in. Any ideas?
Thanks!

firepages
03-22-2004, 03:53 PM
<?
echo '<pre>';
print_r($_SERVER);
?>
will show you all the interesting variables
available to check, take your pick.

I usually do something like..
<?
if(strpos($_SERVER['HTTP_HOST'],$domain_name)!==false){
echo "host is $domain_name";
}
?>

Nightfire
03-22-2004, 03:57 PM
Think it's $_SERVER['SERVER_NAME'] or $_SERVER['HTTP_HOST']



<?php
if($_SERVER['XX'] == "blah.com"){
do stuff
}else{
do nothin
}

Replace XX with one of the above (SERVER_NAME or HTTP_HOST)
<edit>Oops, hi firey one, didn't see your post</edit>

jeremywatco
03-22-2004, 10:06 PM
Excellent thanks.
$_SERVER['HTTP_HOST'] worked great!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum