On a Linux hosting plan you can use an .htaccess file as a powerful tool to help you manage your domain(s). In this particular instance we will use the .htaccess file to block IPs from accessing your domain(s). To get started click on the File Manager icon in your control panel. Click Here if you need assistance with logging into your control panel.
Once the file manager populates in the new window, find and click on the domain you wish to add the the .htaccess file to. You’ll see a list of files and folders similar to the image below.
Look for the File button along the top of the window to the far right, just to the left of Trash. Click on this button and another box will pop up. This is going to be the new file you create. In the name box, delete New_File.txt and replace it with .htaccess.
Click the save button and you should now see the newly created .htaccess file in your domain folder.
Lets take a look at the code line by line: The first line “Order allow,deny” tells the web server the “Order” in which the allow and deny directive will be evaluated. It simply says: Give access to all hosts that are not present in the deny from list and are present in the allow from list. With the allow/deny order, the allow list will be looked up first and then the web server checks the deny from list.
So as we have allow from all – all access is allowed. Then the allowed access is filtered based on the deny list. With allow, deny access is disabled by default. If we change the order to “deny,allow” then all access is enabled by default and only users in the deny lists are blocked. However as the deny is being processed first allow directives will override any matching settings in the deny directives.
Note: Be sure when setting the order there are no spaces in between “allow,deny” (i.e. “Order allow, deny” will generate a 500 error.)
You can use such rules in your .htaccess file to block a particular user or a network from accessing your site. You can put several IP addresses in a deny or allow rule, but they need to be separated by a space or tab. For example:
This will block all users which IP addresses start with 212.155. Alternatively, you can set your .htaccess file to only allow you to access your domain and block all others by adding the following line (BE SURE TO CHECK AND CONFIRM WHAT YOUR IP ADDRESS IS BEFORE ADDING THIS LINE TO THE HTACCESS FILE. ADDING THE WRONG IP ADDRESS WILL BLOCK YOUR ACCESS TO THE SITE):
Where “220.127.116.11″ should be replaced with your computer IP address. Below is an image of where you can get your IP address to your computer.
Using the information provided above will help protect your domains from those nasty DDoS attacks and spammers.