unplugged_web Posted August 2, 2010 Share Posted August 2, 2010 Is it possible to send somebody to a particular site depending on their IP address? I now I can normally do this with root access using .htaccess but I don't have root access for this site and I want to send USA IP's to .com, UK IP's to .co.uk, Australian ones to .au etc. Sorry if this is the wrong place to post this but I thought it might be possible to do it with php?Thanks Link to comment Share on other sites More sharing options...
Tino03 Posted August 2, 2010 Share Posted August 2, 2010 The only thing I can think of at the moment is using $_SERVER['REMOTE_ADDR'] to get the visitors IP address, but I'm not sure how you would go about detecting from which country that IP is. I found this post, which may be of some help, I suppose: here. Link to comment Share on other sites More sharing options...
unplugged_web Posted August 2, 2010 Author Share Posted August 2, 2010 The only thing I can think of at the moment is using $_SERVER['REMOTE_ADDR'] to get the visitors IP address, but I'm not sure how you would go about detecting from which country that IP is. I found this post, which may be of some help, I suppose: here.Thanks, I'll have a look at that, but I'm really trying to do it for when somebody goes to the site for the first time - so they're directed to the right site straightaway. Link to comment Share on other sites More sharing options...
unplugged_web Posted August 2, 2010 Author Share Posted August 2, 2010 I used this: RewriteEngine On RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^UK$ [NC] RewriteRule ^(.*)$ http://myredirection..co.uk [R,L] but just got an Internal Server Error Link to comment Share on other sites More sharing options...
End User Posted August 2, 2010 Share Posted August 2, 2010 Is it possible to send somebody to a particular site depending on their IP address? I now I can normally do this with root access using .htaccess but I don't have root access for this site and I want to send USA IP's to .com, UK IP's to .co.uk, Australian ones to .au etc. Sorry if this is the wrong place to post this but I thought it might be possible to do it with php?Yup, it's possible via PHP: http://jetscripts.com/geotool/So, it's possible and you can do it. You'll need to get an IP-to-country DB and use code to translate the IPs to the country. Link to comment Share on other sites More sharing options...
unplugged_web Posted August 2, 2010 Author Share Posted August 2, 2010 Yup, it's possible via PHP: http://jetscripts.com/geotool/So, it's possible and you can do it. You'll need to get an IP-to-country DB and use code to translate the IPs to the country.okay I think I get that - so I need to add IP's to a database and then use the code I've got to check through and then direct people accordingly?Thanks Link to comment Share on other sites More sharing options...
End User Posted August 2, 2010 Share Posted August 2, 2010 okay I think I get that - so I need to add IP's to a database and then use the code I've got to check through and then direct people accordingly?ThanksYou're better off getting an already populated DB table with the IP and country values. MaxMind.com has a free one I think (may not be updated very often). There also lots of other places to get IP-to-country DBs. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.