htaccess blacklist with mod_rewrite

Asphyxia

Owner
Administrator
Apr 25, 2015
1,845
2
2,199
327
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    ErrorDocument 403 "Your IP is on our blacklist. Appeal this ban by emailing your IP address to: [email protected]"

    RewriteCond %{REMOTE_ADDR} ^1\.
    RewriteRule ^ - [F]
    RewriteCond %{REMOTE_ADDR} ^3\.
    RewriteRule ^ - [F]
    RewriteCond %{REMOTE_ADDR} ^4\.
    RewriteRule ^ - [F]

This would block all IP addresses starting with "1." or "2." or "3." you could also do:
Code:
RewriteCond %{REMOTE_ADDR} ^8\.8\.8\.8
This would block an exact IP address of "8.8.8.8". This needs to go in your website's root directory. The point of this is to reduce the load on your web server by cutting out PHP and database usage. This makes it easier to block an attack.
 
Top