Prerequisites:
with these
- GEOIP (geoip.inc, geoip.dat etc)
- Signup for an account in www.ipinfodb.com
- Download the php class api HERE
- 1. put the geoip files (preferably in a folder) in root directory
- 2. edit the index.php of the root directory and replace these code
/* Store or website code */ $mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : ''; /* Run store or run website */ $mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store'; Mage::run($mageRunCode, $mageRunType);
//########### GEOIP ############// $geoipPath = 'geoip.inc'; include($geoipPath); $gi = geoip_open("GeoIP/GeoIP.dat",GEOIP_STANDARD); $ip = $_SERVER['REMOTE_ADDR']; $country_code = geoip_country_code_by_addr($gi, $ip); if(strtoupper($country_code) != "NL"){ $mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : 'en'; $mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store'; Mage::run($mageRunCode, $mageRunType); }else{ $mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : 'nl'; $mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store'; Mage::run($mageRunCode, $mageRunType); }