How to block only one visitor(by his IP) via .htaccess file?

Hello Everyone!!!

How to block only one visitor(by his IP) via .htaccess file? [Important| Revised 2019]

If you want to deny a single visitor to access your site or you don’t want that visitor to view your site then you can block that visitor by using his IP address.

Here is a code you can write in your .htaccess file to block user from his IP address: [Updated May 2019]

deny from IP Address

For example you can write “deny from 145.241.251.12


Just for testing purpose here in my htaccess i am denying a visitor whose IP is 106.219.176.31 . See the screenshot below-

How to deny only one visitor to access your website via .htaccess file?
How to deny only one visitor to access your website via .htaccess file?
Add caption

Now this code will disallow that IP to access my site, hence it will generate 403 Forbidden error as you can see in the below screenshot

How to deny only one visitor to access your website via .htaccess file?
How to deny only one visitor to access your website via .htaccess file?

Hope this helps you:-)

Thanks for Reading!!!!

Scroll to Top