CentrioHost 24/7 Live Support

 

How to Block certain IP address?

Web servers can host many different domains on one hosting account under Linux/Apache, and public access to each domain and its folders and files can be controlled through the use of a .htaccess file to block a specific IP address, range of IP addresses, or multipleseparate IP addresses. The .htaccess file is typically found in the root folder of your domain (where you would also find the starting page for your web site) and is used for other purposes other than just controlling access to folders and files.

Installing a .htaccess file is not limited to the web site root folder, however. You can install the .htaccess file in any of your sub-folders and the server will apply the rules only to site visitors that attempt to access a file in that folder or any sub-folders below

Allow from All but Deny from a Specific IP Address(es)

The format of the instructions to place into the .htaccess file for blocking access to a protected area is as follows:

order deny,allow
deny from 99.999.999.991
deny from 99.999.999.992
deny from 99.999.999.993
allow from all

These instructions tell the web server to deny all requests to the web site protected area from IP addresses 99.999.999.991, 99.999.999.992, and 99.999.999.993, but allow requests from all other IP addresses.

Deny from All but Allow from a Specific IP Address(es)

You may also want to limit access to a folder only to a specific IP address or range of IP addresses. The format is the same but the contents of the .htaccess is slightly different.

order deny,allow
deny from all
allow from 99.999.999.991
allow from 99.999.999.992
allow from 99.999.999.993

In this case you are denying access from everyone but allowing access to only specific IP addresses or domain names.

Add to Favourites  Add to Favourites    Print this Article  Print this Article

Was this answer helpful?


Hosting Partners
Wildcard SSL Certificates