Allow specific IPs to access your website

For the sake of work or any personal project sometimes you might need to block all IPs and allow only specific ones.

This is easily do-able by editing your .htaccess file. Let’s see how:

Go to your cPanel and find the .htaccess
Go to edit mode
Now paste below code at the very bottom of your .htaccess file

# Allow One IP and Block All
order deny,allow
deny from all
allow from

replace IP by your IP

If you just want to deny access from specific IPs then use this code:

# Allow all Except one IP
deny from IP

replace IP by your IP

Good day.

Web Technology is my cup of coffee & I do photography for fun. I appreciate your visit here.

Leave a Reply

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