开发者

Redirecting with mod_rewrite and mod_geoip only if user asks for the root of the domain and are from a particular country

I need a rule and condition to handle this scenario:

User from US visits www.domain.com, domain.com, www.domain.com/ or domain.com/ this should be redirected to www.domain.com/usvisitor/

However, if a user from the US visits www.domain.com/anydirectory it will let them 开发者_C百科straight through without a redirection occurring.

eg.

RewriteEngine On  
RewriteBase /

GeoIPEnable On  
GeoIPDBFile /var/share/GeoIP/GeoIP.dat  

RewriteEngine on  
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^US$  
RewriteCond %{HTTP_HOST} ^domain.com$ [L]  
RewriteRule ^/$ http://www.domain.com/usvisitor$1 [L]  

I know the RewriteConditons and rules are wrong - just can't get my head around it!


Just for the record got it solved:

RewriteEngine On  

GeoIPEnable On  
GeoIPDBFile /var/share/GeoIP/GeoIP.dat  
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^US$  
RewriteRule ^$ http://www.domain.com/usvisitor/$1 [L,NC,QSA]

Simple really - doh!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜