Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 149
  • Last Modified:

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?
0
Paul Cotter
Asked:
Paul Cotter
  • 3
  • 2
1 Solution
 
Julian HansenCommented:
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

0
 
Paul CotterAuthor Commented:
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...
0
 
Julian HansenCommented:
No it would be a redirect. You can't change the domain name for any given sites. Only redirect between sites.
0
 
Paul CotterAuthor Commented:
Thats what I thought - Thanks Julian:-)
0
 
Julian HansenCommented:
You are welcome - thanks for using EE
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now