Home › Forums › BulletProof Security Pro › Block/Deny access to my website for certain countries?
- This topic has 4 replies, 2 voices, and was last updated 6 years, 11 months ago by AW.
-
AuthorPosts
-
AWParticipant
Hi BPS,
I was wondering, is it possible to write on .htaccess to block my website from being accessible for certain countries?
My website has adsense running on it and I found out that there’s a lot of fake clicks from Pakistan.
If can do so, is there any write up that I can read on how to write it on .htaccess?
Found one code
ifModule mod_geoip.c
GeoIPEnable On
# Add countries you wish to deny here
SetEnvIf GEOIP_COUNTRY_CODE PK DenyCountry
SetEnvIf GEOIP_COUNTRY_CODE ID DenyCountry
Allow from all
Deny from env=DenyCountry
ifModuleDoes the code above works and able to block visitors from India and Pakistan ( ID and PK – country code )
If it works, then could i paste it on the custom code htaccess?Please advise.
Regards,
Alex
AITpro AdminKeymasterSee this forum topic for the steps to create country blocking IP htaccess code: https://forum.ait-pro.com/forums/topic/preventing-countries-from-accessing-site/#post-22206
AWParticipantHi Bps,
Thanks for your awesome article and reply.
I had generated a list of IP from Pakistan and there are about 343 ips to be deny from
Example of generated list as below :-# BLOCK/FORBID Chinese Spammers by CIDR Blocks Deny from 14.1.104.0/22 Deny from 14.192.128.0/19 Deny from 27.0.184.0/22
and so on…..
The question is;-
It has 342 IPS to verify in .htaccess, then would it slow down the page ? ( even a user from non Pakistan )?
Would it increase my server cpu usage and the process level ?
Need your advice on above, cos if all good then I may consider ban India as well.Looking forward for your reply.
Regards,
AlexAITpro AdminKeymasterI don’t think 342 IP addresses in your root htaccess file will cause any significant performance issues, but you can do benchmark testing using “website speed” testing websites to check your website page load speeds.
AWParticipantHello Bps,
Thanks for your reply.
Just put in the code in
Custom Code > Hotlinking > Save custom Code > Activate Root Folder
Tested with Gtmetrix, all seems perfect.
Probably adding another country and will test the speed again. Hope it wouldn’t drag down the speed of the website OR increase the Process and CPU usage in hosting.
Regards,
Alex -
AuthorPosts
- You must be logged in to reply to this topic.