The code that we are using is as follows -
.htaccess
RewriteCond %{HTTP_HOST} .*in.mokshafashions\.com [NC]
RewriteRule .* - [E=MAGE_RUN_CODE:india]
RewriteRule .* - [E=MAGE_RUN_TYPE:website]
RewriteCond %{HTTP_HOST} ^mokshafashions.com [NC]
RewriteRule ^(.*)$ in.mokshafashions.com/$1 [R=301,L]
RewriteRule ^(.*)$ mokshafashions.com/$1$1 [L]
RewriteCond %{REQUEST_URI} !^/admin.* – –
index.php
<?php
define("GEOIP_DAT_FILE", $_SERVER['DOCUMENT_ROOT'] . "/geoip/GeoIP.dat");
define("GEOIP_INC_FILE", $_SERVER['DOCUMENT_ROOT'] . "/geoip/geoip.inc");
include(GEOIP_INC_FILE);
$_geoip = geoip_open(GEOIP_DAT_FILE ,GEOIP_STANDARD);
$_country_code = geoip_country_code_by_addr($_geoip, $_SERVER['REMOTE_ADDR']);
geoip_close($_geoip);
switch ($_country_code) {
case "IN": // India
$_SERVER["MAGE_RUN_CODE"] = "india";
break;
default:
$_SERVER["MAGE_RUN_CODE"] = "base";
}