How to Block an IP Address

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.

  • IPaddress
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

My domain name is not registered with ZillionKingHost can I host my website at ZillionKingHost?

Yes you can host your website with ZillionKingHost.1. Check our hosting packages and  select the...

Termination of hosting accounts

Suspended accounts are terminated based on the billing cycle of the accounts as follows: For...

Why Was My Hosting Account suspended?

There are various reasons why your account was suspended. 1. It may have been suspended because...

How to Migrate from your Previous Host to ZillionKingHost

Migrating from your previous host to ZillionKingHost  can be a very smooth process or it can...

How to Force SSL on all pages on your website using the .htaccess file

To force all web traffic to use HTTPS insert the following lines of code in the .htaccess...