.htaccess: Blocco paese con mod_geoip
Passo 1:
Con un file .htaccess e mod_geoip, puoi escludere l'accesso al tuo sito web da determinati paesi o interi continenti.Ogni paese ha un codice specifico. Qui trovi un elenco di tutti i codici paese a due lettere secondo ISO 3166:
Lista codici paese
I codici per i continenti sono i seguenti:
AF Africa
AN Antartide
AS Asia
EU Europa
NA Nord America
OC Oceania
SA Sud America
Passo 2:
Accedi a WebFTP con i tuoi dati FTP.Modifica il file .htaccess nella directory principale dell'account o del dominio interessato. Se non esiste un file .htaccess, creane uno.
Passo 3:
Per bloccare l'accesso da determinati paesi (ad esempio, Cina e Russia), inserisci le seguenti righe in cima al tuo file .htaccess:
GeoIPEnable On
SetEnvIf GEOIP_COUNTRY_CODE RU BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE CN BlockCountry
Deny from env=BlockCountry
GeoIPEnable On
SetEnvIf GEOIP_CONTINENT_CODE AS BlockContinent
Deny from env=BlockContinent
Passo 4:
Se vuoi invece consentire l'accesso al tuo sito web solo da determinati paesi (ad esempio, Germania, Regno Unito e USA) ed escludere tutti gli altri, inserisci le seguenti righe nel file .htaccess:
GeoIPEnable On
SetEnvIf GEOIP_COUNTRY_CODE DE AllowCountry
SetEnvIf GEOIP_COUNTRY_CODE GB AllowCountry
SetEnvIf GEOIP_COUNTRY_CODE US AllowCountry
Deny from all
Allow from env=AllowCountry
GeoIPEnable On
SetEnvIf GEOIP_CONTINENT_CODE EU AllowContinent
Deny from all
Allow from env=AllowContinent
Supporto e FAQ