Get Paid to Participate - up to $1 per post!     Twitter     Facebook     Google+
Hosting Discussion
 

forgot password?



Reply


Old
  Post #1 (permalink)   01-29-2014, 12:27 AM
HD Amateur
 
Join Date: Jun 2008
Location: New Jersey
Posts: 77

Status: Gaby-HostDept is offline
Can any one explain me how to redirect a website according to visitor location like www.example.com should redirect to us.example.com for united states visitor
 
 
The Following User Says Thank You to Gaby-HostDept For This Useful Post:


Old
  Post #2 (permalink)   02-04-2014, 08:22 PM
HD Newbie
 
Join Date: Jan 2014
Location: Montreal
Posts: 14

Status: TSHosting is offline
While I can't help how to exactly achieve this, I looked into exactly this for my site a couple of weeks back and was advised on another forum (where I was looking to hire someone to do this for me) that it was a really bad idea to re-direct based on location/IP; if you're doing this for language purposes, the argument is that people living in certain places may not speak the native language.

Just my 2 cents =)
 
 
 
The Following User Says Thank You to TSHosting For This Useful Post:


Old
  Post #3 (permalink)   02-04-2014, 10:23 PM
HD Amateur
 
Join Date: Mar 2013
Location: Montreal, Canada
Posts: 78
Send a message via Skype™ to rowebca

Status: rowebca is offline
Quote:
Originally Posted by Gaby-HostDept View Post
Can any one explain me how to redirect a website according to visitor location like www.example.com should redirect to us.example.com for united states visitor
You can use mod_geoip, or geoip extension for php, with GeoIP.dat database from Maxmind and simple with .httaccess:

Code:
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(US)$
RewriteRule ^(.*)$ http://www.us.example.com$1 [R,L]

or with php (with geoip extension):

Code:
$ip = $_SERVER['REMOTE_ADDR'];
$co = geoip_country_code_by_name($ip);
if($co == "US")
{
header("Location: http://us.example.com");    
}
else {
// do whatever you want
}

Regards
__________________
George B. | ROWEBCA
Web Hosting Services & Server Management
Skype : rowebca

Last edited by rowebca : 02-04-2014 at 10:27 PM.
 
 
 
The Following User Says Thank You to rowebca For This Useful Post:


Old
  Post #4 (permalink)   02-05-2014, 07:24 AM
HD Community Advisor
 
ughosting's Avatar
 
Join Date: Jan 2011
Location: London
Posts: 634

Status: ughosting is offline
If you are doing this purely for the language selection, then the above answers are good and there are plenty of PHP examples using the maxmind "free" database available.

If you are using this to divert to servers nearer the location of the customer, this would be most efficiently done using a CDN service.
__________________
DDoS Protected, LiteSpeed + LiteMage on CloudLinux with SSD Disks, R1Soft, Softaculous, SIteBuilder, BitNinja, LetsEncypt & Patchman
UnixGuru: Accounts with 1-20 CPU Cores, 2-40GB RAM. Why use a VPS?
█ Choose from Shared, Reseller and Elastic-Sites Hosting
 
 
 
The Following User Says Thank You to ughosting For This Useful Post:


Old
  Post #5 (permalink)   02-07-2014, 09:45 AM
HD Amateur
 
Join Date: Jun 2008
Location: New Jersey
Posts: 77

Status: Gaby-HostDept is offline
Quote:
Originally Posted by rowebca View Post
You can use mod_geoip, or geoip extension for php, with GeoIP.dat database from Maxmind and simple with .httaccess:

Code:
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(US)$
RewriteRule ^(.*)$ http://www.us.example.com$1 [R,L]

or with php (with geoip extension):

Code:
$ip = $_SERVER['REMOTE_ADDR'];
$co = geoip_country_code_by_name($ip);
if($co == "US")
{
header("Location: http://us.example.com");    
}
else {
// do whatever you want
}

Regards
Thank you for the help
__________________
Follow us on star sports live...
 
 
 
The Following User Says Thank You to Gaby-HostDept For This Useful Post:


Old
  Post #6 (permalink)   02-07-2014, 06:35 PM
HD Amateur
 
Join Date: Jul 2013
Posts: 56

Status: Gaiacom_LC is offline
I think this is easiest to do in conjunction with a CDN. You can leverage their intelligence for visitor location.
__________________
| SolVPS (www.solvps.com) 100% SSD Linux & Windows VPS Hosting
| Managed VPS - Web Hosting - Domains & SSL Certificates | Follow us on Twitter @solvps_hosting
 
 
 
The Following User Says Thank You to Gaiacom_LC For This Useful Post:


Old
  Post #7 (permalink)   02-14-2014, 05:39 PM
HD Addict
 
Join Date: May 2012
Location: Internet
Posts: 140

Status: oneilonline is offline
For any dynamic website you would also need to replicated databases to ensure the data from those is also location optimized.
__________________
WattaServer.com
Performance & Quality Dedicated Servers & Virtual Private Servers
80+ CPU Types, 28 Locations, Affordable Prices & Excellent Support!
99.9% Uptime, Multi-homed BGP Network, DDoS, Managed Services, and more!
 
 
 
The Following User Says Thank You to oneilonline For This Useful Post:


Old
  Post #8 (permalink)   01-27-2018, 05:55 AM
HD Newbie
 
Join Date: Jan 2018
Location: Scotland
Posts: 23

Status: zerohosting is offline
It seems simple to do, then you need to update the website to have us price etc.

But how do you do it with WHMCS you just create different packages with dollars?
__________________
Zero Hosting
Unlimited Web Hosting - ZERO Limitations
ZeroHosting.co.uk
Facebook | Twitter | Instagram
 
 
 


Old
  Post #9 (permalink)   01-27-2018, 02:00 PM
HD Newbie
 
Join Date: Dec 2017
Posts: 12

Status: Evolution Host is offline
If you're hosting your own DNS servers, this can also be done at the DNS level. One benefit of this is that in addition to serving a version of the website with a relevant language and currency etc, you can also direct the user to a web server that is near to them to reduce load time.

See https://doc.powerdns.com/md/authorit...backend-geoip/ as an example of software that can be used to do this.
__________________
Evolution Host - Hosting for KVM VPS, IRCds, mIRC Bots and Game Servers.
Premium hosting at affordable prices.
 
 
 
Reply

Thread Tools

New Post New Post   Old Post Old Post
Posting Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Sponsored By: