GeoIp deny some nations but not a single IP

Discussion in 'Server Operation' started by adrenalinic, Feb 28, 2008.

  1. adrenalinic

    adrenalinic Member

    Hello.

    1) I want lock some nations to access the default web site,
    2) Redirect one nation to other address
    3) Allow some IP of the redirected nation to see the default site (1).

    Default site: domain.info
    Subdomain: test.domain.info
    Redirect AU users to test.domain.info

    Following there is my htaccess code that works good, but I not want apply the redirect from my ip 111.111.111.111 :confused:


    RewriteEngine on

    RewriteCond %{HTTP_HOST} ^domain\.info
    RewriteRule (.*) http://www.domain.info/$1 [R=301,L]

    #Redirect for example AU country
    RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^AU$
    RewriteRule ^(.*)$ http://test.domain.info/$1 [L]
    Allow from 111.111.111.111

    RewriteRule ^([a-z0-9]+)$ /?L=users.profile&id=$1 [r=301,NC]
    RewriteCond !^(stats\.html) [r=301,NC]

    SetEnvIf GEOIP_COUNTRY_CODE CN BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE RU BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE IR BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE IQ BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE KP BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE KR BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE CU BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE LY BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE KP BlockCountry
    SetEnvIf GEOIP_COUNTRY_CODE SY BlockCountry

    Deny from env=BlockCountry


    Very thanks.
    Josef.
     
  2. falko

    falko Super Moderator Howtoforge Staff

    Try something like this instead:

    Code:
    #Redirect for example AU country
    RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^AU$
    RewriteCond %{REMOTE_ADDR} !^111.111.111.111$
    RewriteRule ^(.*)$ http://test.domain.info/$1 [L]
     

Share This Page