Solved

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

Posted on 2014-10-30
5
113 Views
Last Modified: 2014-10-30
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
Comment
Question by:Paul Cotter
  • 3
  • 2
5 Comments
 
LVL 51

Expert Comment

by:Julian Hansen
ID: 40413505
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
 

Author Comment

by:Paul Cotter
ID: 40413536
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
 
LVL 51

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 40413682
No it would be a redirect. You can't change the domain name for any given sites. Only redirect between sites.
0
 

Author Comment

by:Paul Cotter
ID: 40413698
Thats what I thought - Thanks Julian:-)
0
 
LVL 51

Expert Comment

by:Julian Hansen
ID: 40413755
You are welcome - thanks for using EE
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now