Blocking Users

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.

FileManagerIcon

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.

htaccessFileList

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.

htaccessNew

Click the save button and you should now see the newly created .htaccess file in your domain folder.

htaccessFileList1

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.

  • Order allow,deny
  • allow from all

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.

  • Order deny,allow
  • deny from 192.168.0.10
  • deny from 212.155.
  • deny from 1.2.3.4 5.6.7.8 127.0.0.1
  • allow from all

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:

  • Deny from 1.2.3.4 5.6.7.9
  • To block an entire network:
  • deny from 212.155.

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):

  • deny from all
  • allow from 1.2.3.4

Where “1.2.3.4″ should be replaced with your computer IP address. Below is an image of where you can get your IP address to your computer.

Commandprompt

Using the information provided above will help protect your domains from those nasty DDoS attacks and spammers.

Was this article helpful?

Yes (1)
No (0)

We're sorry you didn't find this article very helpful. Please help us improve it by leaving your feedback below.

Error