Jump to content

IP detection


unplugged_web

Recommended Posts

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

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

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

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

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
You'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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...