How to Block an IP Address With Htaccess

How to Block an IP Address With Htaccess thumbnail
Block IP addresses in your .htaccess file.

The ".htaccess" file is a plain text file located in the root of your website domain directory. The .htaccess file controls several functions for the website including IP blocks. You can block IP addresses if you feel a website owner is scraping content or trying to hack your web server. The .htaccess file only requires one line of code to block an IP address, but you must enter a new line for each IP address you want to block.

Instructions

    • 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.

Related Searches:

References

  • Photo Credit computer image by Orlando Florin Rosu from Fotolia.com

Comments

You May Also Like

Related Ads

Featured