WEB Block countries and redirect them to another url

Discussion in 'OT Technology' started by Browning, Jan 19, 2009.

  1. Browning

    Browning Active Member

    Joined:
    Feb 14, 2005
    Messages:
    89,465
    Likes Received:
    10
    I want to block a couple countries from viewing a site of mine, but redirect them to another domain. What would be the easiest way of doing this?
     
  2. maxxpower

    maxxpower OG Lauren Crew - Observer OT Supporter

    Joined:
    May 27, 2007
    Messages:
    26,348
    Likes Received:
    0
  3. Browning

    Browning Active Member

    Joined:
    Feb 14, 2005
    Messages:
    89,465
    Likes Received:
    10
    found this but I'm not sure if it works or not. Looks like something is missing:dunno:

    Code:
    RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CN$ [NC,OR]
    RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^SA$ [NC,OR]
    RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^IR$ [NC,OR]
    RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^MM$ [NC,OR]
    RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^SG$ [NC,OR]
    RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^KP$ [NC,OR]
    RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^KR$ [NC,OR]
    RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^HK$ [NC,OR]
    RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^RU$ [NC,OR]
    RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^ZA$ [NC,OR]
    RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CF$ [NC,OR]
    RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^VN$ [NC,OR]
    RewriteRule ^(.*)$ http://domain.com [R,L] 
     
  4. maxxpower

    maxxpower OG Lauren Crew - Observer OT Supporter

    Joined:
    May 27, 2007
    Messages:
    26,348
    Likes Received:
    0
    That would only work if the GEOIP variables are being collected from a source.
    Easiest way to do it would be to use the IP ranges from the site above and add it to the rewrite cond

    So it would look like so..

    Code:
    RewriteCond %{REMOTE_ADDR} ^123.\.123\.124\. [NC,OR]
    RewriteCond %{REMOTE_ADDR} ^123.\.123\.124\. [NC,OR]
    RewriteRule ^(.*)$ http://myredirect.com [R,L] 
    
    Something along those lines.
     
  5. Yahdude

    Yahdude New Member

    Joined:
    Jun 21, 2006
    Messages:
    1,211
    Likes Received:
    0
    Location:
    PC, UT
  6. Browning

    Browning Active Member

    Joined:
    Feb 14, 2005
    Messages:
    89,465
    Likes Received:
    10
    now I'm lost:o
     

Share This Page