2

We are currently running Magento 1.9.0.1 CE for our online store. We have a domain example.com and a subdomain in.example.com

We use in.example.com specifically for customers from India whereas everybody else is meant for example.com. We are currently using geoip database to redirect. The issues that we are facing are as follows -

  1. if somebody from India opens example.com/page.html they get redirected to in.example.com instead of in.example.com/page.html

  2. if somebody from USA opens in.example.com they are not getting redirected to example.com at all. same is also true for in.example.com/page.html

  3. even with these redirects we want example.com/admin to not get redirected whether accessing from India or USA.

Code that I have used is as follows -

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.* – –
1

1 Answer 1

1

I'm not an mod_rewrite expert, but I'll try.

To fix 1. and 2. you have to add the path and all parameters, this should work:

RewriteRule ^(.*)$ http://in.example.com$1 [L]

RewriteRule ^(.*)$ http://example.com$1 [L]

The last problem can be fixed while just avoiding the redirect, this should work like this:

RewriteCond %{REQUEST_URI} !^/admin.*
5
  • Greetings @Fabian, This doesn't work much for me. Maybe I am not writing the redirect condition wrong. Attaching below the code I am using. Kindly let me know what changes I need to make. Much appreciated. #RewriteBase /magento/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.* –
    – Vipul Jain
    Commented Jun 2, 2015 at 11:21
  • I don't understand why the formatting is not working. use double space as well as <br/> tag.
    – Vipul Jain
    Commented Jun 2, 2015 at 11:24
  • edit your question if you want formatting. comments only allow ``` Commented Jun 2, 2015 at 12:23
  • I hope it makes more sense now. edited the question itself.
    – Vipul Jain
    Commented Jun 2, 2015 at 13:33
  • still not working. This is causing fatal error. Moreover admin goes to in.mokshafashions.com
    – Vipul Jain
    Commented Jun 3, 2015 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.