Link to home
Start Free TrialLog in
Avatar of Paul Cotter
Paul Cotter

asked on

can I get a different domain name to show for my site if it is accesed from another country.

can I get a different domain name to show for my site if it is accessed from another country. I have a joomla site with a plugin that can show different content depending on IP but Im curious as to whether I can make the domain name change too. Say I have a .com and when someone accesses from UK they will see .co.uk - is this possible?
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Yes it is possible - you have to redirect the site.

In your code you have some script that does a lookup in GeoLocation database (Check out Maxmind or similar)

That gives you your country - you then decide if you want to redirect and simply issue a header command

header('location: yourdomain.co.uk');

Open in new window


Full code would be something like

$ip = $_SERVER['REMOTE_ADDR'];
$country = get_country($ip); // CHANGE TO WHATEVER GeoLocation DB API YOU ARE USING
if ($country == 'UK') {
   header('location: yourdomain.co.uk');
}

Open in new window

Avatar of Paul Cotter
Paul Cotter

ASKER

Thanks Julian - Im not really great with code. Are we actually redirecting the site or pretending to? I want the same site but with a different URL showing in UK only...
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thats what I thought - Thanks Julian:-)
You are welcome - thanks for using EE