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

forgot password?



FORUM SUPPORTERS:

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: 88
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 2 Users Say Thank You to rowebca For This Useful Post:
techperx (09-26-2018)


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

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.
__________________
UnixGuru High Performance, Low Contention, Litespeed Hosting
Elastic Sites (HIgh Powered Hosting Accounts) with 1 to 20 CPU Cores, 4 to 42GB of RAM. (Power of a VPS with the ease of Shared Hosting)
PHP and Node.JS on Shared, Reseller, & VPS 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: 150

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.
 
 
 


Old
  Post #10 (permalink)   03-11-2018, 06:56 AM
HD Newbie
 
Join Date: Dec 2017
Posts: 3

Status: hostpanel is offline
You can detect geolocation by IP address using the free IP2Location LITE.

There is a code generator to produce the redirection script based on your instruction.

https://www.ip2location.com/free/visitor-redirection
 
 
 


Old
  Post #11 (permalink)   03-12-2018, 01:06 PM
HD Amateur
 
Join Date: Jan 2018
Location: India
Posts: 96
Send a message via Skype™ to webconfigure

Status: webconfigure is offline
The provided code and CDN will help you in this case. Also if you are using the CMS for developing the website then there are plugins which will help you to achieve the requires result.
 
 
 


Old
  Post #12 (permalink)   03-19-2018, 04:19 AM
HD Amateur
 
Join Date: Aug 2017
Posts: 55

Status: PeterShene is offline
I dont know why you would want to force a redirect , like somebody said above the person may well not speak the language you are assuming he is.

Anyway i have done this for a website before, and from a seo perspective google does not like the redirect as it is termed a re direct and not good for user experience.

What google does advise is sub directories with copies of you web page in the language and then using the appropriate href lang tags.

Landing on a English site and seeing the word ( Francias or whatever ) as a link on there for those whom would prefer it is a much better way of implementing this.

If your href tags have been implemented properly and you are showing them on google webmaster tools and have the sub directory then google will be well aware that you offer the site in both languages and now forcing a german guy whom probably uses english online to a german version of the your site.
__________________
Web design east london
 
 


Old
  Post #13 (permalink)   05-09-2018, 05:07 AM
HD Newbie
 
Join Date: Apr 2018
Location: India
Posts: 19

Status: arihantwebtech is offline
If you doing because of language issue then you not need to do this. Just used language relational code in your header section google can find it.
 
 
 


Old
  Post #14 (permalink)   09-26-2018, 12:13 PM
HD Newbie
 
Join Date: Aug 2018
Location: Delhi, India
Posts: 42

Status: techperx is online now
Thanks rowebca for this valuable information. I was also looking for this kind of help. Thanks once again.
__________________
TechPerx - Digital Marketing
New Delhi, India
 
 
 
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: