Take the 2-minute tour ×

This question already has an answer here:

I have 2 websites with different domain extensions that provide the same services for the visitors, one is .com and the other is .com.au. I want to give access to the Australian people only visit to .com.au website not to .com, so they cannot visit the .com website.

Would you please guide me how to restrict access of those Australian visitors to the .com website? Even if they use the typo in the address bar of the browser's they'll automatically will be redirected to the .com.au website.

As I'm not a techno guy, I need your firm guidance make this happen. Thank you for your assistance.

share|improve this question
add comment

marked as duplicate by Quentin, deceze, Baba, nickb, Marc B May 9 '13 at 16:47


1 Answer

First get a geolocation based on their ip, here

The maxmind service for locating countries is here

There should be some free services just google around and i am sure you will be able to find them

But basically just load the php library of whichever service you find, feed it the ip of the visitor $_SERVER['REMOTE_ADDR']

then do a redirect to the .au address if the geolocation comes up with a Australian result

header('location: http://www.example.com.au');

put the check at the top of your script(s)

share|improve this answer
add comment
