Logo Your Web Hosting Solution
.htaccess Guide
Directory Listing
Error Messages
Password Popup
Redirect Pages
Protect Images
Block Users
.htaccess Tools
Tutorials Index
Home Page
.htaccess Tutorial - Block An IP Address

There may be times where you want to refuse access to certain robots or human visitors to your web site.

1. Basic .htaccess file

order allow,deny
deny from
allow from all

This will refuse all GET and POST requests made by IP address, an error message is shown instead.

2. More options

To block multiple IP addresses, list them one per line.

order allow,deny
deny from
deny from
deny from
allow from all

You can also block an entire IP block/range. Here we will not specify the last octet in the .htaccess file.

deny from 127.0.0

This will refuse access for any user with an address in the to range.

Instead of using numeric addresses, domain names (and subdomain names) can be used to ban users.

deny from isp_name.com

It bans users with a remote hostname ending in isp_name.com. This would stop all users connected to the internet via isp_name.com from viewing your site.

Using .htaccess to block an entire range or name is likely to lock out innocent users. Use with caution.

Top Of Page 
Copyright© 1996 - 2018 Clockwatchers, Inc.