How to Block an IP Address With Htaccess
- 1). Right-click the .htaccess file in your website directory and select "Open With." In the list of programs, double-click "Notepad" to open the .htaccess file in the text editor.
- 2). Scroll down to the section labeled "order allow,deny." You can also quickly find this section by clicking the "Edit" menu item and select "Find." Enter "order allow,deny" into the text box. If there is no "order allow,deny" section, add this text to the first line of your .htaccess file.
- 3). Enter the IP address you want to block. For example, the following code blocks the "192.168.1.1" IP address:
deny from 192.168.1.1
Repeat this line for each IP address you want to block. - 4). Click the "File" menu item and select "Save" to save your changes to the .htaccess file.