BIOS,Windows, Linux, Software,Security, Domains, Web Hosting

Block IP Address From Website On Apache

There are 3 ways to block (ban) IP address from accessing website in Apache: Modify httpd.conf, redirect IP to another predefined page, and using .htaccess.

The below statement assumes we will block or ban IP 12.34.56.78 from port 80.

1. Setting httpd.conf to block

Add these settings in httpd.conf:

NameVirtualHost 12.34.56.78:80
<VirtualHost 12.34.56.78:80>
     ServerName 12.34.56.78
     <Location />
     Order Allow,Deny
     Deny from all
     </Location>
</VirtualHost>

2. Redirect IP to another page

Also set this in httpd.conf, Configuration as:

NameVirtualHost 12.34.56.78:80
<VirtualHost 12.34.56.78:80>
ServerName 12.34.56.78
DocumentRoot "/srv/www/default"
</VirtualHost>

3. Setting .htaccess

If you want to block IP from some bad users, add this in your .htaccess.

Order Deny,Allow
Deny from 12.34.56.78

To block a IP range, for example 12.34.56.x, like this:

Order Deny,Allow
Deny from 12.34.56.
Allow from all

Related Articles

Comments(0)  

Leave a Reply

Subscribe to BootBeta Comments RSS feed to receive notification of latest comments posted.

Subscriptions

  • Enter Email Address:

Recent Post

Copyright@ 2010-2014 Bootbeta All Rights Reserved.
HooBlog Ver 1.5 Build 20140530