Blocking IP address for blog comment, how?

by cktan
4 replies
One of my WP blogs is getting lots of comment spam recently and seems like my Akismet simply cant stop them.. After doing some investigation I found that 90% of these comments came from 1 country, so I just wonder is there any way to block all the comments which come from certain countries?

Thanks!
#address #blocking #blog #comment
  • Profile picture of the author Dennis Gaskill
    You can block IP addresses using an .htaccess file, so you can block a country by listing all the IP addresses that country owns. I don't know if there's any other way to do it.

    You can generate an .htaccess file at this website that will block any country by simply selecting the country and click a button.

    That can be a lot of IP addresses, and I've never blocked an entire country, so I don't know if this will slow down your site or not. You'll have to see for yourself unless someone comes through with a better way.
    Signature

    Just when you think you've got it all figured out, someone changes the rules.

    {{ DiscussionBoard.errors[1912882].message }}
    • Profile picture of the author halfpoint
      You can get the plugin wp-ban and block ip's from your blog entirely.
      {{ DiscussionBoard.errors[1913145].message }}
  • Profile picture of the author webdevuk
    You could block it using PHP

    On the blog commenting file include ("blog_comment.php") something like that.

    At the top simply put
    note: 00.00.00.00 == IP Address to block
    -----------------------------------------

    if($_SERVER['REMOTE_ADDR'] == "00.00.00.00"){
    die("Sorry IP Blocked");
    }
    {{ DiscussionBoard.errors[1913291].message }}
  • Profile picture of the author bizousoft
    What country will that be? But the plug in is a good choice. wp-ban works fine with me.
    {{ DiscussionBoard.errors[1913626].message }}

Trending Topics