Main Page / Browse Categories / Howto's & Guides / Htaccess / Deny/Block Users
Deny/Block Users
If you'd like to prevent certain people from visiting your website, you can block them from doing so. By utilizing the .htaccess file, you can block certain persons by either an IP address or even a domain name. To do so, simply follow the tutorial laid out for you below.
 

Note: If you already have a .htaccess file you'd like to use, amend the following to the existing .htaccess file.

Open Notepad (or equivalent software depending on your OS) and paste in the following:

order allow,deny
deny from 127.0.0.1
allow from all

The above allows for you to deny a certain user at a single specified IP Address. To block multiple users, simply add more deny lines underneath the one that's already there. To block users from an IP range, the following can be used in place of the deny line above:

deny from 127.0.0.

Leaving off the last digit will block all users from 127.0.0.0 to 127.0.0.255. This is classified as an IP range. If you'd like to block a certain website, than the domain option might be the one you wish to use:

deny from somesite.com

This will allow for you to deny access to your site from this specific domain. To add multiple domains, simply add addition deny lines. However, if you'd like to deny access to a domain and all subdomains under that domain, try this:

deny from .somesite.com

This will deny access from somesite.com, as well as from anything.somesite.com
Save the file as htaccess (add . at the beginning and remove the .txt extension).

Upload the htaccess.txt file via FTP in ASCII mode and place in the httpdocs folder.
After uploaded right click the file (server copy) and choose rename
Edit the file name, so that it will be .htaccess (add a . to the beginning and drop the .txt extension)

The users you've blocked will now not be able to access your site. Enjoy!



User Comments
Deny/Block Users
Add Comment
There are no user comments for this topic.
Add Comment
Additional Info
General Information
Article No. 193
Created: 04:33 AM 12.26.03
Author: HPU Support

Attachments
No attachments.

Did this help you?
Yes No

Statistics
Yes627 (50%) Voted Yes632 (50%) Voted NoNo

Other Options
Print Article
Email Article

Related Articles
Understanding htaccess
Custom Errors
Password Protection