与mod_rewrite的和mod_geoip重定向只有当用户请求域的根,是来自某一特定国家重定向、国家、用户、mod_rewrite

由网友(假装不合适)分享简介:我需要一个规则和条件来处理这种情况:I need a rule and condition to handle this scenario:用户来自美国的访问www.domain.com,domain.com,www.domain.com/或domain.com/~~V这应该被重定向到www.domain.com/...

我需要一个规则和条件来处理这种情况:

I need a rule and condition to handle this scenario:

用户来自美国的访问www.domain.com,domain.com,www.domain.com/或domain.com/~~V这应该被重定向到www.domain.com/usvisitor /

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

但是,如果从美国访问用户www.domain.com/anydirectory~~V这将让他们直接通过没有重定向发生。

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

如:

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]  

我知道RewriteConditons和规则是错误的 - 只是不能让我的头周围

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!

阅读全文

相关推荐

最新文章