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
127 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 55

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 55

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 55

Expert Comment

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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
query of query sort 6 106
SAMI File <SYNC Start = (number of millisecond)> Question 3 79
site launch date and last modified date 3 98
Animated .jpg? 13 95
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to count occurrences of each item in an array.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

809 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