1

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

coloradohiker
  • 221
  • 3
  • 11

1 Answers1

1

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]
Ulrich Palha
  • 9,411
  • 3
  • 25
  • 31
  • Follow up to my original question. I have css, image, and javascript paths that refer back to the original root/store/skin directory. With the htaccess rewrite in place it was rewriting those paths to root/ukstore/skin which doesn't exist and was breaking all of those links. Is there a way to have the url rewrite in place but leave paths to the skin directory untouched? – coloradohiker Feb 01 '12 at 14:47
  • @coloradohiker see edits above to skip `/store/skin/directory` – Ulrich Palha Feb 01 '12 at 14:52
  • One more question. Our checkout pages are https and within that, it still is rewriting the secure url for the skin and js pages. Is there a way to ignore it within the https as well? Thanks again for all your help. – coloradohiker Feb 01 '12 at 17:30
  • Interesting issue cropped up in regards to the above rule. I'm using the GeoIP to detect for multiple countries and then send them to austore. If someone accesses from New Zealand they get redirected to austore no problems, images, js, css are all there. The links to those files are ignored so it still reads store/skin If someone accesses from Australia then all of those links are broken and rewritten to austore/skin/. Any thoughts on that issue? Also, still having issues with all https rewriting to the austore/skin. Thanks! – coloradohiker Feb 02 '12 at 15:27
  • @coloradohiker I need more details about both issues e.g. an example of the URL that is being rewritten under HTTPS and how you would like it to behave. Same thing with austore/skin issue. They are both probably easy to address. Also suggest that you create a new post with the details as it is easier than via comments, and it will get the attention of everyone on SO. – Ulrich Palha Feb 02 '12 at 15:59
  • [link](http://stackoverflow.com/questions/9116240/htaccess-rewrite-rules-with-mod-geoip) for more details! Thanks! – coloradohiker Feb 02 '12 at 16:45