2012-01-26 64 views
1

我使用mod_geoip为我的电子商务网站将客户从澳大利亚重定向到同一服务器上的不同店面。该商店位于根/商店/,我希望他们被重定向到根/澳大利亚/htaccess条件重写规则与mod_GeoIP

我已经得到它,所以基本重写工作完美,但我希望url结构是相同的。例如,如果有人点击root/store/category/product /并且他们居住在海外的链接,我希望他们被重定向到root/austore/category/product /,因为两个商店的文件结构都是相同的。现在,如果他们点击该链接,它会将它们重定向到基本根目录/ austore /。

这是现在的重写规则。

Options +FollowSymLinks 
RewriteEngine on 
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^AU$ 
RewriteRule ^([^/]+)$ /austore/ [L] 

我正在编辑的.htaccess文件位于store /目录中。

任何帮助将不胜感激。谢谢!

艾伦

回答

1

尝试

#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] 
+0

这完美地工作。谢谢您的帮助! – coloradohiker 2012-01-30 18:07:40

+0

追溯到我原来的问题。我有css,image和javascript路径,这些路径指向原来的root/store/skin目录。随着htaccess的重写,它重写了那些不存在的根/ ukstore/skin的路径,并打破了所有这些链接。有没有一种方法来重新编写url,但保留到skin目录的路径不变? – coloradohiker 2012-02-01 14:47:58

+0

@coloradohiker请参阅上面的编辑以跳过'/ store/skin/directory' – 2012-02-01 14:52:54