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.

  • Block IP
  • 1 Utenti hanno trovato utile questa risposta
Hai trovato utile questa risposta?

Articoli Correlati

Cant Access My Site?

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

500 Internal Server Error

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

How to Transfer cPanel Accounts from another Server?

This tutorial will show you how you can create FULL BACKUP and remotely upload this to your new...

How to Switch Hosts?

Switching to a new host can be a very smooth process or it can be very complicated. Following...

How to Transfer Email Accounts and Messages Between cPanel Servers?

If you want to transfer the email accounts and messages for a domain from one server to...