仅当用户请求域的根并且来自特定国家/地区时才使用 mod_rewrite 和 mod_geoip 进行重定向
我需要一个规则和条件来处理这种情况:
来自美国的用户访问www.domain.com、domain.com、www.domain.com/或domain.com/,这应该被重定向到www.domain.com/usvisitor/
但是,如果来自美国的用户访问 www.domain.com/anydirectory,它将让他们直接通过,而不会发生重定向。
例如。
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 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 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是为了记录一下,解决了这个问题:
真的很简单 - 哦!
Just for the record got it solved:
Simple really - doh!