How to Block a Range of IP Addresses

By  on  

As much as content creators want traffic to their website, there is such thing as the wrong type of traffic. Sometimes it's content scrapers, sometimes it's malicious bots; either way, it's important to know how to block problematic IPs from your site.

To block a range of IP addresses using an .htaccess file, you can use the * wildcard for pieces of the IP address:

Order Allow,Deny
Deny from 219.198.*.*
Allow from all

You can also use a regular expression:

RewriteEngine on
RewriteCond %{REMOTE_ADDR} ^219\.198\.\.
RewriteRule ^ - [F]

Don't let known attackers and problematic bots bring your website to a halt! Be quick to check your site logs and ban addresses that are causing havoc!

Recent Features

  • By
    Create Namespaced Classes with MooTools

    MooTools has always gotten a bit of grief for not inherently using and standardizing namespaced-based JavaScript classes like the Dojo Toolkit does.  Many developers create their classes as globals which is generally frowned up.  I mostly disagree with that stance, but each to their own.  In any event...

  • By
    Facebook Open Graph META Tags

    It's no secret that Facebook has become a major traffic driver for all types of websites.  Nowadays even large corporations steer consumers toward their Facebook pages instead of the corporate websites directly.  And of course there are Facebook "Like" and "Recommend" widgets on every website.  One...

Incredible Demos

  • By
    Scroll IFRAMEs on iOS

    For the longest time, developers were frustrated by elements with overflow not being scrollable within the page of iOS Safari.  For my blog it was particularly frustrating because I display my demos in sandboxed IFRAMEs on top of the article itself, so as to not affect my site's...

  • By
    MooTools FontChecker Plugin

    There's a very interesting piece of code on Google Code called FontAvailable which does a jQuery-based JavaScript check on a string to check whether or not your system has a specific font based upon its output width. I've ported this functionality to MooTools. The MooTools...

Discussion

  1. Jose Cerrejon

    Who is using Apache today? Just kidding. Do you know how to achieve the same using Nginx? Thanks in advance.

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!