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.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

.htaccess - Fun with it !

Introduction The Apache web server has a number of configuration options that are available to...

500 Internal Server Error

Internal Server Error help, 500 error Internal server errors can be caused by a few different...

Cant Access my site?

We receive lots of queries from our client saying that why i'm not being able to access my site....

Do you provide AwStats?

Yes, we provide AWSTATS most of the servers of Centriohost.com and it is updated automatically...

How to change a php.ini value?

We use suPHP in all of our servers. This is the common reason why php_flag or php_value doesn't...

Powered by WHMCompleteSolution