How to block unwanted traffic to your website from specific IPs
If you are using our new Control Panel, refer to this article.
Make the switch and discover a simpler, more secure way to manage your hosting.
Malicious or unwanted traffic to your website can be blocked by adding a snippet of code to the .htaccess file within your site content.
It’s possible to block traffic from specific IPs or a range of IPs from visiting your website. Even traffic from entire countries can be blocked.
No coding or experience is required – just follow the steps below.
Block IPs using .htaccess
The .htaccess file is located in the public_html directory of your website content. If you only want to block access to certain parts of your site, you can create a new .htaccess file and upload it to the relevant subdirectory.
This file can be accessed and edited in various ways, including FTP and SSH. Here we will access it via the konsoleH File Manager:
- Browse to konsoleH and log in (Admin or Domain level)
- If Admin level: Select or search for a domain name in the Hosting Services tab
- Click Manage Services from the left-hand menu
- Select File Manager. The files within the public_html folder are immediately visible – these are website files and includes the .htacess file that governs your whole site.
- Click .htaccess in your file list, then click Edit from the right-hand menu.
- Insert the following code snippet at the top or bottom of any other code that is already in the text file, replacing the sample IPs with those that you want to be blocked. Any number of IPs can be listed. Click Save changes
order allow,deny deny from 123.456.789.01 deny from 12.123.456.78 deny from 234.56.789.123 allow from all
Should you wish to block traffic to your website from a particular region, you can make use of IP2Location API.
Cloudbric, the security service offered by us, provides a dashboard to easily block IPs or countries. Log in to the xneelo Control Panel to access.