If you want to block or whitelist specific IP addresses, you can do it with an IP Manager.

If you prefer doing changes via .htaccess or you want to create settings for a list of addresses, all you need to do is:

  1. Create .htaccess file in your public_html folder

  2. Add lines based on your preferences.

Option 1 - Block or allow specific IP addresses

To set rules for specific addresses, you can use this template:

Order Allow,Deny
Deny from 185.185.185.185
Allow from all

In the example above, IP address 185.185.185.185 is blocked and won’t be able to reach your website.

If you want to block several addresses, just add them from the new line:

Order Allow,Deny
Deny from 185.185.185.185
Deny from 192.192.192.192

NOTE: Allow from line is optional if you only want to deny access, and vice versa.

Option 2 - Block or allow ranges of IP addresses

You can set rules for whole ranges or subnets of IP addresses by setting from-to values in IP address:

Order Allow,Deny 
Deny from 185.185.185.0/24
Allow from all

And by using * for the whole octets:

Order Allow,Deny
Deny from 185.185.*.*
Allow from all

Option 3 - Block specific countries

If you want to set rules for the whole country or several countries, you can easily do it with Cloudflare.

Did this answer your question?