First make sure that you have created a file with name .htaccess at your root directory
To block certain ip address from accessing your website paste below rules on your .htaccess file.
order allow,deny deny from 192.168.0.100 allow from all |
Where The first line “Order allow, deny” tells the web server the “Order” in which the Allow and Deny directive will be evaluated. It simply says: Give access to all hosts that are not present in the Deny from list and are present in the Allow from list. With allow, deny order Allow list is looked up first and then the web server checks the deny from list. So as we have allow from all – all access is allowed. Then the allowed access is filtered based on the Deny lists. With allow,deny access is disabled by default.
If you want to block multiple ip address then follow below commands.
order allow,deny deny from 192.168.0.100 deny from 192.168.0.101 deny from 192.168.0.102 deny from 192.168.0.103 allow from all |
You can also block certain network range like 192.168.0.0 – 192.168.0.199
order allow,deny deny from 192.168.0 allow from all |
To block all access to your site
order allow,deny Deny from all |
And then add another line to enable access only for particular ip
order allow,deny Deny from all Allow from 192.168.0.100 |