Reputation: 221
I'm using mod_geoip for my ecommerce site to redirect customers from Australia to a different storefront on the same server. The store is located at root/store/ and I want them to be redirected to root/austore/
I've got it so the basic rewrite works flawlessly, but I want the url structure to be the same. For example, if someone clicks on a link that is root/store/category/product/ and they live overseas, I want them to be redirected to root/austore/category/product/ because the file structure is the same for both stores. As it is right now, if they click on that link, it will redirect them to just the basic root/austore/.
Here is the rewrite rule as it is right now.
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^AU$
RewriteRule ^([^/]+)$ /austore/ [L]
The .htaccess file I'm editing is in the store/ directory.
Any help would be greatly appreciated. Thanks!
Allan
Upvotes: 1
Views: 679
Reputation: 9529
Try
#skip processing /store/skin/ directory
RewriteRule ^store/skin/ - [L,NC]
#if they live overseas i.e not Australia
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} !^AU$
#if someone clicks on a link that is root/store/category/product/
RewriteCond %{REQUEST_URI} ^/store(/.*)$ [NC]
#I want them to be redirected to root/austore/category/product/
RewriteRule ^ /austore%1 [L,R]
Upvotes: 1