Magento redirection with htaccess based on country wise

Hi,

I have created multiple stores based on country wise. Now I have multiple domains in a single magento installation. All are working rocks. But I can access all stores in a single country. It kills all of my hard works. Now We need to overcome it by our smart work.

For example, if i open UK store from india, it must automatically redirect to Indian store and vice versa.

We can done it by adding following Geoip code in UK stores .htaccess file

GeoIPEnable On
ReWriteEngine On  
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} IN$
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
RewriteRule ^ http://www.myindiadomain.in [R=301,L]

In Indian store .htaccess file replace with UK country code and domain instead of Indian country code and Domain

If you want to access admin only from anywhere, Just add the following condition code before Rewrite rule

RewriteCond %{REQUEST_URI} !admin
RewriteCond %{REQUEST_URI} !index.php [NC]

Have any doubt, Please comment here!

You can also refer following threads

Some admin modules redirect to frontend

Magento redirection with htaccess

Leave a comment