Заблокировать страны ЕС для доступа к моему сайту через .htaccess? - PullRequest
0 голосов
/ 25 мая 2018

Привет, у меня есть базовый HTML-сайт с несколькими страницами.Я хочу заблокировать доступ из стран ЕС через файл .htaccess, который у меня есть, в мой корневой каталог.Я вставил этот код поверх файла htaccess, но, похоже, не вносил никаких изменений.

<ifModule mod_geoip.c>

GeoIPEnable On
# Add countries you wish to deny here

SetEnvIf GEOIP_COUNTRY_CODE AL DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE AD DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE AM DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE AT DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE AM DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE AZ DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE BY DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE BE DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE BA DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE BG DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE HR DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE CY DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE CZ DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE DK DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE EE DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE FI DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE FR DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE GE DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE DE DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE GR DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE HU DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE IS DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE IE DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE IT DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE KZ DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE LV DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE LI DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE LT DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE LU DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE MK DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE MT DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE MD DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE MC DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE ME DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE NL DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE NO DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE PL DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE PT DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE RO DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE RU DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE SM DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE RS DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE SK DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE SI DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE ES DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE SE DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE CH DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE TR DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE UA DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE GB DenyCountry

SetEnvIf GEOIP_COUNTRY_CODE VA DenyCountry
Allow from all

Deny from env=DenyCountry

</ifModule>

Может кто-нибудь помочь мне с этим?Может не работает из-за того, что mod_geoip.c не включен как модуль в cPanel?

1 Ответ

0 голосов
/ 09 августа 2018

Я рекомендую создать страницу на другом веб-сайте, чтобы сообщить им, что они потеряли доступ к вашему сайту именно из-за GDPR.Затем посетитель из страны ЕС будет перенаправлен на эту страницу.

Вам потребуется разрешение sudo и запуск Apache, потому что для этого требуется модуль Apache IP2Location для запуска.

Вы можете использовать это для генерации кода: https://www.ip2location.com/free/visitor-redirection#source-codes

Код:

    <!-- language: htaccess -->
    RewriteEngine On

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^AT$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^BE$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^BG$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^HR$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^CY$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^CZ$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^DK$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^EE$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^FI$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^FR$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^DE$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^GR$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^HU$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^IE$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^IT$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^LV$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^LT$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^LU$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^MT$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^NL$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^PL$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^PT$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^RO$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^SK$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^SI$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^ES$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^SE$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]

    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^GB$
    RewriteRule ^(.*)$ https://example.com/gdpr-page/ [L]
...