0

Block IP Address from accessing your website using .htaccess

Spread the love

In this post i will tell you how you can ban/block a visitor to visit your website using IP address and .htaccess.You have faced many problems like robot scripts continue pinging your site,commenting and site server down issues.Or sometime someone is copying your site data.If you relate to these types of issues and want to block that users IP then this post is for you.You can use .htaccess for this and can block a user without any stress in miniutes.

Block IP Address using .htaccess, Block IPs with .htaccess, Block Visitors by Country, Deny visitors by IP address, How To Block Bots

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.

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.

You can also block certain network range like 192.168.0.0 – 192.168.0.199

To block all access to your site

And then add another line to enable access only for particular ip

Leave a Reply

Your email address will not be published. Required fields are marked *