View Single Post
  #2 (permalink)  
Old Dec 10th, 2005, 04:15
grahame grahame is offline
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Domain alias redirection with PHP?

The HTTP_REFERER is for the previous page - the one from which your user followed a link to get to your site. The HTTP_HOST is the host name through which the current host was contacted.

We have several domains with the same main section and we bring in the following from an include file:
Code: Select all
$host = explode(".",$_SERVER[HTTP_HOST]);
$sitefirst = $host[0];
$sitelast = $host[count($host)-1];
and we're then set up (for example) with "net", "uk" or "com" in $sitelast and with "www", "java" or "ireland" in $sitefirst ... so that we have one set of site files but serve subtley varied content. We even switch content completely on occasions to an alternative page without the need for a messy redirect. From later in our header file:
Code: Select all
$page = explode("/",substr($_SERVER[SCRIPT_NAME],1));
$filename = $page[count($page)-1];
$fullfilename = implode("_",$page);
$alternate = "$_SERVER[DOCUMENT_ROOT]/alternate/$host[0]_$fullfilename";
if (file_exists($alternate)) {
include ($alternate);
exit ();
}
Reply With Quote