How to block IP addresses using IP Manager or .htaccess

Do you have a problem with malicious users trying to threaten the security of your ? We have you backed. In this article, we will walk you through the steps on how to block an IP address using ‘s IP Manager (hPanel) tool and .htaccess. In addition, we will teach you how to perform geo-blocking with .htaccessso you can prevent an entire country from accessing your site.

Why would you want to block IPs?

There are a number of reasons why you should consider using the IP address blocking feature, here are a few examples:

  • Damage to your bandwidth: spammers and bots consume your website’s bandwidth. Protect your website and your visitors by blocking their activity.
  • malicious content: Bots often spread comments that contain unwanted information. You get nothing from their presence other than phishing links that contain potential viruses and malware.
  • Hackers: If you often find suspicious activities on your website, you are most likely under hacker attack. Simply deny their access by blocking their IP address or prevent any entry to your website for everyone except you.

Blocking addresses with the hPanel IP Manager

There are a couple of methods to block an IP address from accessing your site. The easiest way would be to do it using the function IPManager in the Control Panel of your hosting. If you’re on , this will only take a few minutes.

This is how you can do it:

1. Open your hPanel, then navigate to the section IPManager within the area Others.

2. In the box Block an IP addressenter the IP address you want to block in the text box IP to deny and additional comments in the text box Grades. Once you’re done, click Add.

See also  Top 18 eCommerce Trends You Should Know About in 2022

3. If the process is successful, a confirmation message will appear on your screen.

Congratulations! You have blocked access to the user of that particular IP address. To prevent multiple IP addresses from accessing your site, you can repeat these steps as many times as necessary.

You can reverse this action by repeating the same steps in the column Allow one IP or by removing the settings at the bottom of the page.

Block an IP address using .htaccess

Another way to block an IP address is by using , which is a file that you can access if you are running Apache as your web server ( uses Apache). By denying access to an IP address in the Apache web server configuration file, the ban process can be executed before your site is fully loaded.

Here’s how to do it through your file .htaccess:

1. Open ‘s hPanel, then navigate to the section file manager within the area Records.

2. Open the file .htaccess located in the directory public_html clicking on the file and then use the function Edit on the toolbar.

You can also do this by connecting your account through the FTP client (see for more information on this method).

3. Once the page opens edit fileinsert the following lines above the existing code

Order Deny, Allow Deny from 192.168.1.2 Allow from all

This code will block access from the IP address 192.168.1.2. If you want to block another address just copy that line and paste it below. Prior to Allow from all, you can paste as many lines as you want. Also make sure to create a backup of the original code in case of failure. Once you’re done, click Save&Close.

See also  Payment Methods at

That is all! Pretty easy and quick, right?

How to ban a group of users using .htaccess

If for some reason you want to ban users from a specific location, what you have to do is write the range of IP addresses as follows:

Order Allow, Deny Deny from 192.168.1. Allow from all

As you can see, a number has been removed, which means that any IP address that starts with 192.168.1 will be banned from your site.

If the group you want to ban has dynamic IPs, then you can search for the hostname. For example, if the service provider is called badisp.com, you can ban all its users as follows:

Order Allow, Deny Deny from badisp.com Allow from all

Geoblocking with .htaccess

There are cases where the attacks come from a certain country. Or, you probably don’t want your content to be accessible in some countries for specific reasons. To solve this problem, you can deny access from a particular country using the file .htaccess.

1. Open the file.htaccess In the address book public_html. Leave it open for now.

2. Generate a list of IP addresses from the country of your choice in this . To do so, click on the country name, then set the format to Apache .htaccess Deny. Once you’re done, click Create ACL.

3. Copy the code into the generated list in the .htaccess file, then click Save&Close.

4. Your site is now accessible to users from all over the world, except those who reside in the country to which you have denied access.

See also  How to check the A Record of a domain

conclusion

Blocking an IP address is one of the best ways to protect your website from malicious attacks. Contrary to popular belief, it can be easily done using the IP Manager and the file .htaccess.

To block an IP address with IP Manager, you must:

  1. Open IP Manager in hPanel.
  2. Enter the target IP address in the section Block an IP address.

If you choose to use the .htaccess file instead, you must:

  1. open section file manager in the hPanel.
  2. open the file .htaccess In the address book public_html using the function Edit.
  3. Adds the syntax containing the destination IP address along with its access permission.

Or you can ban a group of users by removing the last IP number or including the host name.

You can also block access to your site from a certain country using the file .htaccess:

  1. open the file .htaccess In the address book public_html using the function Edit.
  2. Generates a list of IP addresses of the destination country in this .
  3. Copy the generated list code to the file .htaccess

And ready! With these methods to block an IP, your site will be a safe place for everyone, especially you.

Deyi is a digital marketing enthusiast, with a background in web design, content creation, copywriting, and SEO. She is part of ‘s SEO & Localization team. In her free time, she likes to develop projects, read a book or watch a good movie.

Loading Facebook Comments ...
Loading Disqus Comments ...