If you want to block access to your website for specific IP addresses, you can do this in two different ways:
- in the « .htaccess » file in the «Document Root» of the corresponding website
- or directly in the Plesk Control Panel
1. In the .htaccess file
The easiest way to find the «Document Root» is in the Plesk Control Panel under the point «Websites & Domains» by clicking on «Files» in the «Dashboard».
If there is no file named « .htaccess » yet, you can create and edit the file directly there in the directory «httpdocs».
You can create new directories and files in the Plesk Control Panel by clicking on «». Alternatively, you can also create the file locally on your computer and directly upload it to the File Explorer.
To block access, for example, for the IP address 1.2.3.4, enter the following lines in the « .htaccess file» :
order allow,deny
deny from 1.2.3.4
allow from all
If you want to block multiple IP addresses, enter each one on a separate line:
order allow,deny
deny from 1.2.3.4
deny from 2.3.4.5
allow from all
This blocks access for the corresponding IP addresses for all subdirectories of your website as well.
2. Directly in the Plesk Control Panel
- To do this, log in to the Plesk Control Panel.
- Click on «Websites & Domains» > «Hosting & DNS» and then on «Apache & nginx».
- Select «Deny website access» under «General Apache Settings» and then choose «Enter custom value».
> This will open two additional fields where you can enter IP addresses or IP ranges:
- that should be blocked (blacklist)
- that should always have access (whitelist)
- Save your entries by clicking «OK».