If you are a Plesk user on a Linux hosting plan looking to enhance the security of your website by blocking access to certain IP addresses, you can do so by modifying the .htaccess file. This file is used to make configuration changes on the web server.
Prerequisites
> Plesk hosting account
> Access to Plesk's File Manager
> The IP address(es) you wish to block
Step 1: Access the File Manager
1. Log in to your Plesk control panel.
2. Click on Websites & Domains.
3. Find the domain for which you want to block the IP address, and click on File Manager.
Step 2: Locate or Create the .htaccess File
1. In the File Manager, navigate to the httpdocs
directory, which is the root directory of your website.
2. Look for the .htaccess
file. If it already exists, click to select it, then click Edit in the top menu.
3. If the .htaccess
file does not exist, you can create it by clicking New, then Create File, and name it .htaccess
.
Step 3: Edit the .htaccess File to Block the IP Address
1. Add the following code to your .htaccess
file to block a single IP address:
order allow,deny
deny from 123.123.123.123
allow from all
> Replace 123.123.123.123 with the IP address you wish to block.
2. To block multiple IP addresses, add a deny from
line for each IP address:
order allow,deny
deny from 123.123.123.123
deny from 124.124.124.124
allow from all
3. To block an entire IP range, specify the range in the deny from
directive:
order allow,deny
deny from 123.123.123
allow from all
> This will block all IP addresses that begin with 123.123.123
.
4. Once you have added the necessary lines to block the desired IP addresses or ranges, click on "OK" or "Save" to apply the changes.
By following these steps, you can effectively manage access to your website and enhance its security using the .htaccess file in your Plesk hosting environment. Always ensure that you understand the rules you're implementing, as incorrect settings can potentially lock you out of your own website or impact your website's availability to legitimate visitors.