How to block access to the site by unwanted visitors.
1. Blocking bots on UserAgent. Add to the .htaccess line file:
SetEnvIfNoCase User-Agent ^ BadBot getout
SetEnvIfNoCase User-Agent ^ EvilBot getout
Order Allow, Deny
Allow from all
Deny from env = getout
Then we enter this file in the basic directory of the site (usually public_html) and the bots on UserAgent with the beginning of BadBot and EvilBot will not be able to access the site.
2. We block Referrer traffic. By adding the .htaccess file line:
SetEnvIfNoCase referer "^ http: //bad.domain.com/evilscript.php" blocked = 1
Order Allow, Deny
Deny from env = blocked
Allow from all
Then we enter this file in the main folder of the site (usually public_html) and the script http://bad.domain.com/evilscript.php will no longer be able to send you traffic.
3. We block traffic by country
Add to .htaccess:
SetEnvIf GEOIP_COUNTRY_CODE CN BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE RU BlockCountry
(And so on for all the countries you want to block)
Deny from env = BlockCountry
Also Read