0

Redirect domain according to country IP address using php or .htaccess

In this post i will discuss how  to redirect a domain according to country IP using PHP and .htaccess.you can write .htaccess rules that filter and redirect site in country domains.On the other hand if you have multiple sites according to different countries and you are looking for an answer to divert sites according to related country then this post is for you.You can use both PHP or .htaccess for this work.

geo redirection, geoip redirect wordpress, geolocation redirect script, htaccess redirect based on country, javascript redirect based on ip address, redirect based on country wordpress, redirect visitors by country, redirect website based on location

Suppose you have three sub domain like http://au.example.com, http://us.example.com, http://in.example.com Australia, USA, India.
And If some one type http://example.com then he/she redirected county specific url as per geo ip location.

Here is the solution.

By PHP

First of all download geoplugin library and call it on your page.
http://www.geoplugin.com/_media/webservices/geoplugin.class.phps

Here is the country code list for geoplugin and you can find easily.
http://www.geoplugin.com/iso3166

By .htaccess

First you need to check that you have the mod_geoip module (GeoIP Extension) installed and configured on your server, If yes then tweak your .htaccess file accordingly..

Leave a Reply

Your email address will not be published. Required fields are marked *