Block certain countries using Cloudflare and HTACCESS

Note - only use if you have Cloudflare

Are you are tired of getting hammered by hackers from other countries? It could be that a large portion of your bandwidth is used up by bots constantly trying to infiltrate your vulnerable areas.

This list blocks every country bar the following:

  • US - United States
  • AU - Australia
  • UK - United Kingdom
  • CA - Canada
  • NZ - New Zealand

Note: The United States does hit my wordpress websites hard with bots, but there are likely still legit customers from there. It might not be so bad to block them too if you only want Australia visitors

SetEnvIf CF-IPCountry AF GoAway=1
SetEnvIf CF-IPCountry AX GoAway=1
SetEnvIf CF-IPCountry AL GoAway=1
SetEnvIf CF-IPCountry DZ GoAway=1
SetEnvIf CF-IPCountry AS GoAway=1
SetEnvIf CF-IPCountry AD GoAway=1
SetEnvIf CF-IPCountry AO GoAway=1
SetEnvIf CF-IPCountry AI GoAway=1
SetEnvIf CF-IPCountry AQ GoAway=1
SetEnvIf CF-IPCountry AG GoAway=1
SetEnvIf CF-IPCountry AR GoAway=1
SetEnvIf CF-IPCountry AM GoAway=1
SetEnvIf CF-IPCountry AW GoAway=1
SetEnvIf CF-IPCountry AC GoAway=1
SetEnvIf CF-IPCountry AT GoAway=1
SetEnvIf CF-IPCountry AZ GoAway=1
SetEnvIf CF-IPCountry BS GoAway=1
SetEnvIf CF-IPCountry BH GoAway=1
SetEnvIf CF-IPCountry BD GoAway=1
SetEnvIf CF-IPCountry BB GoAway=1
SetEnvIf CF-IPCountry BY GoAway=1
SetEnvIf CF-IPCountry BE GoAway=1
SetEnvIf CF-IPCountry BZ GoAway=1
SetEnvIf CF-IPCountry BJ GoAway=1
SetEnvIf CF-IPCountry BM GoAway=1
SetEnvIf CF-IPCountry BT GoAway=1
SetEnvIf CF-IPCountry BO GoAway=1
SetEnvIf CF-IPCountry BA GoAway=1
SetEnvIf CF-IPCountry BW GoAway=1
SetEnvIf CF-IPCountry BV GoAway=1
SetEnvIf CF-IPCountry BR GoAway=1
SetEnvIf CF-IPCountry IO GoAway=1
SetEnvIf CF-IPCountry VG GoAway=1
SetEnvIf CF-IPCountry BN GoAway=1
SetEnvIf CF-IPCountry BG GoAway=1
SetEnvIf CF-IPCountry BF GoAway=1
SetEnvIf CF-IPCountry BI GoAway=1
SetEnvIf CF-IPCountry KH GoAway=1
SetEnvIf CF-IPCountry CM GoAway=1
SetEnvIf CF-IPCountry CV GoAway=1
SetEnvIf CF-IPCountry KY GoAway=1
SetEnvIf CF-IPCountry CF GoAway=1
SetEnvIf CF-IPCountry TD GoAway=1
SetEnvIf CF-IPCountry CL GoAway=1
SetEnvIf CF-IPCountry CN GoAway=1
SetEnvIf CF-IPCountry CX GoAway=1
SetEnvIf CF-IPCountry CC GoAway=1
SetEnvIf CF-IPCountry CO GoAway=1
SetEnvIf CF-IPCountry KM GoAway=1
SetEnvIf CF-IPCountry CG GoAway=1
SetEnvIf CF-IPCountry CD GoAway=1
SetEnvIf CF-IPCountry CK GoAway=1
SetEnvIf CF-IPCountry CR GoAway=1
SetEnvIf CF-IPCountry CI GoAway=1
SetEnvIf CF-IPCountry HR GoAway=1
SetEnvIf CF-IPCountry CU GoAway=1
SetEnvIf CF-IPCountry CY GoAway=1
SetEnvIf CF-IPCountry CZ GoAway=1
SetEnvIf CF-IPCountry CS GoAway=1
SetEnvIf CF-IPCountry DK GoAway=1
SetEnvIf CF-IPCountry DJ GoAway=1
SetEnvIf CF-IPCountry DM GoAway=1
SetEnvIf CF-IPCountry DO GoAway=1
SetEnvIf CF-IPCountry TP GoAway=1
SetEnvIf CF-IPCountry EC GoAway=1
SetEnvIf CF-IPCountry EG GoAway=1
SetEnvIf CF-IPCountry SV GoAway=1
SetEnvIf CF-IPCountry GQ GoAway=1
SetEnvIf CF-IPCountry ER GoAway=1
SetEnvIf CF-IPCountry EE GoAway=1
SetEnvIf CF-IPCountry ET GoAway=1
SetEnvIf CF-IPCountry EU GoAway=1
SetEnvIf CF-IPCountry FK GoAway=1
SetEnvIf CF-IPCountry FO GoAway=1
SetEnvIf CF-IPCountry FJ GoAway=1
SetEnvIf CF-IPCountry FI GoAway=1
SetEnvIf CF-IPCountry FR GoAway=1
SetEnvIf CF-IPCountry FX GoAway=1
SetEnvIf CF-IPCountry GF GoAway=1
SetEnvIf CF-IPCountry PF GoAway=1
SetEnvIf CF-IPCountry TF GoAway=1
SetEnvIf CF-IPCountry GA GoAway=1
SetEnvIf CF-IPCountry GM GoAway=1
SetEnvIf CF-IPCountry GE GoAway=1
SetEnvIf CF-IPCountry DE GoAway=1
SetEnvIf CF-IPCountry GH GoAway=1
SetEnvIf CF-IPCountry GI GoAway=1
SetEnvIf CF-IPCountry GB GoAway=1
SetEnvIf CF-IPCountry GR GoAway=1
SetEnvIf CF-IPCountry GL GoAway=1
SetEnvIf CF-IPCountry GD GoAway=1
SetEnvIf CF-IPCountry GP GoAway=1
SetEnvIf CF-IPCountry GU GoAway=1
SetEnvIf CF-IPCountry GT GoAway=1
SetEnvIf CF-IPCountry GG GoAway=1
SetEnvIf CF-IPCountry GN GoAway=1
SetEnvIf CF-IPCountry GW GoAway=1
SetEnvIf CF-IPCountry GY GoAway=1
SetEnvIf CF-IPCountry HT GoAway=1
SetEnvIf CF-IPCountry HM GoAway=1
SetEnvIf CF-IPCountry HN GoAway=1
SetEnvIf CF-IPCountry HK GoAway=1
SetEnvIf CF-IPCountry HU GoAway=1
SetEnvIf CF-IPCountry IS GoAway=1
SetEnvIf CF-IPCountry IN GoAway=1
SetEnvIf CF-IPCountry ID GoAway=1
SetEnvIf CF-IPCountry IR GoAway=1
SetEnvIf CF-IPCountry IQ GoAway=1
SetEnvIf CF-IPCountry IE GoAway=1
SetEnvIf CF-IPCountry IM GoAway=1
SetEnvIf CF-IPCountry IL GoAway=1
SetEnvIf CF-IPCountry IT GoAway=1
SetEnvIf CF-IPCountry JM GoAway=1
SetEnvIf CF-IPCountry JP GoAway=1
SetEnvIf CF-IPCountry JE GoAway=1
SetEnvIf CF-IPCountry JO GoAway=1
SetEnvIf CF-IPCountry KZ GoAway=1
SetEnvIf CF-IPCountry KE GoAway=1
SetEnvIf CF-IPCountry KI GoAway=1
SetEnvIf CF-IPCountry KP GoAway=1
SetEnvIf CF-IPCountry KR GoAway=1
SetEnvIf CF-IPCountry XK GoAway=1
SetEnvIf CF-IPCountry KW GoAway=1
SetEnvIf CF-IPCountry KG GoAway=1
SetEnvIf CF-IPCountry LA GoAway=1
SetEnvIf CF-IPCountry LV GoAway=1
SetEnvIf CF-IPCountry LB GoAway=1
SetEnvIf CF-IPCountry LS GoAway=1
SetEnvIf CF-IPCountry LR GoAway=1
SetEnvIf CF-IPCountry LY GoAway=1
SetEnvIf CF-IPCountry LI GoAway=1
SetEnvIf CF-IPCountry LT GoAway=1
SetEnvIf CF-IPCountry LU GoAway=1
SetEnvIf CF-IPCountry MO GoAway=1
SetEnvIf CF-IPCountry MK GoAway=1
SetEnvIf CF-IPCountry MG GoAway=1
SetEnvIf CF-IPCountry MW GoAway=1
SetEnvIf CF-IPCountry MY GoAway=1
SetEnvIf CF-IPCountry MV GoAway=1
SetEnvIf CF-IPCountry ML GoAway=1
SetEnvIf CF-IPCountry MT GoAway=1
SetEnvIf CF-IPCountry MH GoAway=1
SetEnvIf CF-IPCountry MQ GoAway=1
SetEnvIf CF-IPCountry MR GoAway=1
SetEnvIf CF-IPCountry MU GoAway=1
SetEnvIf CF-IPCountry YT GoAway=1
SetEnvIf CF-IPCountry MX GoAway=1
SetEnvIf CF-IPCountry FM GoAway=1
SetEnvIf CF-IPCountry MD GoAway=1
SetEnvIf CF-IPCountry MC GoAway=1
SetEnvIf CF-IPCountry MN GoAway=1
SetEnvIf CF-IPCountry ME GoAway=1
SetEnvIf CF-IPCountry MS GoAway=1
SetEnvIf CF-IPCountry MA GoAway=1
SetEnvIf CF-IPCountry MZ GoAway=1
SetEnvIf CF-IPCountry MM GoAway=1
SetEnvIf CF-IPCountry NA GoAway=1
SetEnvIf CF-IPCountry NR GoAway=1
SetEnvIf CF-IPCountry NP GoAway=1
SetEnvIf CF-IPCountry NL GoAway=1
SetEnvIf CF-IPCountry AN GoAway=1
SetEnvIf CF-IPCountry NT GoAway=1
SetEnvIf CF-IPCountry NC GoAway=1
SetEnvIf CF-IPCountry NI GoAway=1
SetEnvIf CF-IPCountry NE GoAway=1
SetEnvIf CF-IPCountry NG GoAway=1
SetEnvIf CF-IPCountry NU GoAway=1
SetEnvIf CF-IPCountry MP GoAway=1
SetEnvIf CF-IPCountry NO GoAway=1
SetEnvIf CF-IPCountry OM GoAway=1
SetEnvIf CF-IPCountry PK GoAway=1
SetEnvIf CF-IPCountry PW GoAway=1
SetEnvIf CF-IPCountry PS GoAway=1
SetEnvIf CF-IPCountry PA GoAway=1
SetEnvIf CF-IPCountry PG GoAway=1
SetEnvIf CF-IPCountry PY GoAway=1
SetEnvIf CF-IPCountry PE GoAway=1
SetEnvIf CF-IPCountry PH GoAway=1
SetEnvIf CF-IPCountry PN GoAway=1
SetEnvIf CF-IPCountry PL GoAway=1
SetEnvIf CF-IPCountry PT GoAway=1
SetEnvIf CF-IPCountry PR GoAway=1
SetEnvIf CF-IPCountry QA GoAway=1
SetEnvIf CF-IPCountry RE GoAway=1
SetEnvIf CF-IPCountry RO GoAway=1
SetEnvIf CF-IPCountry RU GoAway=1
SetEnvIf CF-IPCountry RW GoAway=1
SetEnvIf CF-IPCountry GS GoAway=1
SetEnvIf CF-IPCountry KN GoAway=1
SetEnvIf CF-IPCountry LC GoAway=1
SetEnvIf CF-IPCountry VC GoAway=1
SetEnvIf CF-IPCountry WS GoAway=1
SetEnvIf CF-IPCountry SM GoAway=1
SetEnvIf CF-IPCountry ST GoAway=1
SetEnvIf CF-IPCountry SA GoAway=1
SetEnvIf CF-IPCountry SN GoAway=1
SetEnvIf CF-IPCountry RS GoAway=1
SetEnvIf CF-IPCountry YU GoAway=1
SetEnvIf CF-IPCountry SC GoAway=1
SetEnvIf CF-IPCountry SL GoAway=1
SetEnvIf CF-IPCountry SG GoAway=1
SetEnvIf CF-IPCountry SK GoAway=1
SetEnvIf CF-IPCountry SI GoAway=1
SetEnvIf CF-IPCountry SB GoAway=1
SetEnvIf CF-IPCountry SO GoAway=1
SetEnvIf CF-IPCountry ZA GoAway=1
SetEnvIf CF-IPCountry ES GoAway=1
SetEnvIf CF-IPCountry LK GoAway=1
SetEnvIf CF-IPCountry SH GoAway=1
SetEnvIf CF-IPCountry PM GoAway=1
SetEnvIf CF-IPCountry SD GoAway=1
SetEnvIf CF-IPCountry SR GoAway=1
SetEnvIf CF-IPCountry SJ GoAway=1
SetEnvIf CF-IPCountry SZ GoAway=1
SetEnvIf CF-IPCountry SE GoAway=1
SetEnvIf CF-IPCountry CH GoAway=1
SetEnvIf CF-IPCountry SY GoAway=1
SetEnvIf CF-IPCountry TW GoAway=1
SetEnvIf CF-IPCountry TJ GoAway=1
SetEnvIf CF-IPCountry TZ GoAway=1
SetEnvIf CF-IPCountry TH GoAway=1
SetEnvIf CF-IPCountry TG GoAway=1
SetEnvIf CF-IPCountry TK GoAway=1
SetEnvIf CF-IPCountry TO GoAway=1
SetEnvIf CF-IPCountry TT GoAway=1
SetEnvIf CF-IPCountry TN GoAway=1
SetEnvIf CF-IPCountry TR GoAway=1
SetEnvIf CF-IPCountry TM GoAway=1
SetEnvIf CF-IPCountry TC GoAway=1
SetEnvIf CF-IPCountry TV GoAway=1
SetEnvIf CF-IPCountry UG GoAway=1
SetEnvIf CF-IPCountry UA GoAway=1
SetEnvIf CF-IPCountry AE GoAway=1
SetEnvIf CF-IPCountry UY GoAway=1
SetEnvIf CF-IPCountry SU GoAway=1
SetEnvIf CF-IPCountry UZ GoAway=1
SetEnvIf CF-IPCountry VU GoAway=1
SetEnvIf CF-IPCountry VA GoAway=1
SetEnvIf CF-IPCountry VE GoAway=1
SetEnvIf CF-IPCountry VN GoAway=1
SetEnvIf CF-IPCountry VI GoAway=1
SetEnvIf CF-IPCountry WF GoAway=1
SetEnvIf CF-IPCountry EH GoAway=1
SetEnvIf CF-IPCountry YE GoAway=1
SetEnvIf CF-IPCountry ZR GoAway=1
SetEnvIf CF-IPCountry ZM GoAway=1
SetEnvIf CF-IPCountry ZW GoAway=1

Order allow,deny
Allow from all
Deny from env=GoAway