How to block IP addresses via .htaccess

If you want to block access to your website for certain IP addresses, you can do this via the .htaccess file in the "document root" of the website.

The easiest way to get to the document root is in the Control Panel under "Web Sites" by clicking on the link in the "Document Root" column.

If there isn't already a file named ".htaccess", you can create and edit the file directly in the directory.

You can create new directories and files in the Control Panel by entering the file name in the lower right corner. Alternatively, you can also create the file on your computer and upload it via FTP.

To block access, for example for the IP address 1.2.3.4, enter the following lines in the .htaccess file:

.htaccess
order allow, deny
  deny from 1.2.3.4
allow from all

If you want to block multiple IP addresses, enter them in separate lines:

.htaccess
order allow, deny
  deny from 1.2.3.4
  deny from 2.3.4.5
allow from all

This blocks the access for the corresponding IP addresses also for all subdirectories of your web page.

 

Unable to find what you were looking for?

Our support experts are happy to assist you personally!

 

© 2001 - Hostpoint AG