Block/Deny access to my website for certain countries?

Home Forums BulletProof Security Pro Block/Deny access to my website for certain countries?

This topic contains 4 replies, has 2 voices, and was last updated by  AW 11 months, 1 week ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #33191

    AW
    Participant

    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
    ifModule

    Does 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

    #33194

    AITpro Admin
    Keymaster

    See 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

    #33197

    AW
    Participant

    Hi 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,
    Alex

    #33198

    AITpro Admin
    Keymaster

    I 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.

    #33199

    AW
    Participant

    Hello 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

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.