.htaccess question

Discussion in 'Apache' started by wseo, Oct 27, 2008.

  1. #1
    I need to block country. Just i have spam from South Africa (48%).

    How to block users and robots with .htaccess?

    please help.

    Thank you in advance
     
    wseo, Oct 27, 2008 IP
  2. diligenthost

    diligenthost Peon

    Messages:
    685
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You might want to check out blockacountry.com ;) Though you'll be blocking legitimate visitors as well!
     
    diligenthost, Oct 27, 2008 IP
  3. wseo

    wseo Well-Known Member

    Messages:
    151
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #3
    Have some one question. This country have many ip addresses
    example 3000 - one per line? This mean very big .htaccess file.
    Do you have a problem for web server file size of .htaccess - example .htaccess size is 30 kb

    Thank you again
     
    wseo, Oct 27, 2008 IP
  4. Ladadadada

    Ladadadada Peon

    Messages:
    382
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You are probably much better off just blocking the IP addresses that send you spam rather than all IP addresses from that country.

    If the IP addresses change a lot and you don't see the same one twice then maybe try blocking the ISP rather than the whole country. A whois search on the IP address will tell you the whole range owned by that ISP.

    The .htaccess file you get from www.blockacountry.com uses CIDR notation to specify a range of IP addresses, often up to 65,536 of them on a single line. This is far more efficient than one IP address per line. Still, they have been less efficient than they could have been. For instance, when blocking Australia they have blocked nearly the entire 203.19.0.0/16 range (65,536 IP addresses) in around 120 lines of /23 (512 IP addresses) and /24 (256 IP addresses) even though the entire /16 range is Australian and could have been blocked in a single line. (Not that you would want to block Australia...)
    You could probably tidy up their list quite a lot to make the file size smaller.

    Still, I think you would be better off blocking the spamming IP addresses only and not the whole country.

    Good luck.
     
    Ladadadada, Oct 27, 2008 IP
  5. maestria

    maestria Well-Known Member

    Messages:
    705
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #5
    Check in geoip which country range that you want to block.
    Then just issue the command to block a range of IP address and you are on your way.
     
    maestria, Oct 28, 2008 IP