The cart is empty

How to Block an IP Address on Your Website

You’ve probably encountered situations where someone or a bot repeatedly spammed your guestbook, forum, or contact form from a single IP address. An elegant solution is to implement CAPTCHA codes on your pages. If you prefer not to go this route, you can block the spammer by IP address through .htaccess.

To block an IP address from accessing your site, you need to add the following entries to your .htaccess file:

  • The first line specifies whether you are blocking or allowing access.

    Allow,Deny
    
  • At least one address must be allowed; otherwise, all access is denied.
    Deny,Allow
    ​
  • At least one address must be denied; otherwise, all access is allowed.

Example

Order Deny,Allow
Deny from all
Allow from 196.168.1.1
  • Access is allowed from the IP address 196.168.1.1; all other access is denied.

For several years, we have managed large discussion forums and accumulated a substantial database of dangerous IP addresses, including those of spammers and spambots.

You can download the IP address database HERE. Simply unzip the archive and upload it to the /WEB directory of your hosting. If you need to restrict access to visitors from certain countries, you can use online tools such as:

These restrictions can be used against spammers from specific countries, limit foreign traffic, or restrict visits to live chats. Since IP addresses are traded, the list from the generator may become outdated over time. It’s advisable to periodically regenerate the list.