Page 1 of 1

Re-direction based on referrer domain

Posted: Tue Oct 24, 2006 12:36 am
by mattandaniel
Hi there,

I am setting up a site to serve both Australia and New Zealand. The content for both sites is managed within the one CMSMS installation. Does anyone know what would be the best way to re-direct to the appropriate home page based on the referrer URL? That is, I want mysite.com.au to automatically redirect to the australia home page, and mysite.co.nz to automatically redirect to the NZ home page. I was thinking it may involve editing index.php...

thanks

Re: Re-direction based on referrer domain

Posted: Fri Oct 27, 2006 12:29 am
by mattandaniel
In case anyone else needs to do this at some point, I created a user defined tag called 'redirect'. Here is what I put in it:

$domain = $_SERVER['HTTP_HOST'];

if( ($domain == 'www.mysite.com.au') || ($domain == 'mysite.com.au' ) )
{
          header( 'Location: http://www.mysite.com.au/index.php?page=mysite-au-home' ) ;
}
else
{
          header( 'Location: http://www.mysite.com.au/index.php?page=mysite-nz-home' ) ;
}

I then just put it in the content of the home page - seems to work pretty smoothly.