Redirect USA traffic away from a website

Is there a way to redirect traffic away from a site depending on whether it is coming from the USA or elsewhere?

The reason I ask is because we have a worldwide webside and a USA website. When USA people attempt to view the worldwide website they should actually be taken to the USA website instead. Google does this depending on which country you are requesting the page from.

Who is Participating?
Eddie ShipmanConnect With a Mentor All-around developerCommented:
Those techniques don't always work because the user's ISP may also
have his IP range registered in another country.

Unless ICANN renumbers all IP addresses in ranges for specific countries, like
radio station call letters or airplane registration numbers, it isn't going to
be reliable.
Harisha M GCommented:

You need to check the IP address of the user. Typically this can be done using the server-side language like ASP, PHP etc.

craigdevAuthor Commented:
our CMS is php

What would you check the IP address against?
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Harisha M GConnect With a Mentor Commented:
craigdev, each country will have a set of numbers as the first/second octet of the IP address. You need to check whether that IP belongs to USA and redirect using header() if it doesn't.

$_SERVER['REMOTE_ADDR'] tells you the IP address of the user
AutogardConnect With a Mentor Commented:
This is something that is quite difficult to do, even given the IP address, but you can get pretty close:
I agree, hence the "quite difficult to do" ... "but you can get pretty close".  :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.