How to Create .Htaccess to Block an IP Address
Htaccess files are small instruction files placed in the directory of a website on an Apache server. These files are not viewable by users and instead serve as directions to Apache for handling connections to the page. In addition to password protecting and redirecting resources, htaccess files can be used to block access to website's based upon the Internet Protocol (IP) address of the user.
Instructions
-
-
1
Open the Start menu and type "notepad." Then select "Notepad" from the list of utilities.
-
2
Paste the following text into the notepad window:order allow,deny
deny from <IP>
allow from all
-
-
3
Replace <IP> in the pasted text with the IP address you would like to block; for example, "201.34.22.44" and then press "Enter."
-
4
Click "File," and then "Save as."
-
5
Navigate to your website's home directory in the "Save" dialog window.
-
6
Type ".htaccess" including the quotes in the file name field, and then press "Enter" to save the file.
-
1
Tips & Warnings
Blocking additional IP addresses is done by adding more "deny from <IP>" lines to the file.
All "deny" rules must come before the final "allow" rule to be processed.