繁体   English   中英

阻止欧盟国家通过.htaccess访问我的网站?

[英]Block EU countries to access my site via .htaccess?

嗨,我有几页的基本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中的模块,因此可能无法正常工作?

我建议在另一个网站上创建一个页面,让他们知道他们特别是由于GDPR而失去了访问您网站的权限。 然后,来自欧盟国家的访客将被重定向到该页面。

您将需要具有sudo权限并正在运行Apache,因为这需要IP2Location Apache模块才能运行。

您可以使用它来生成代码: 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]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM