- You need to block all access to an internal website, allowing only certain IP addresses
OR - You need to block certain IP addresses from connecting
If you see your self needing to lock down a private website allowing only certain IP addresses to connect, you can use htaccess for this.
You can do the following to lock down a given directory on your server, giving a forbidden HTML code when non-whitelisted IPs try to access the site:
- Login to your server via SSH
- Goto the website directory that you are wanting to lock down - e.g. /home/user1/public_html/admin_interface/
- Create a new file in that directory - or edit the existing - file with the name of .htaccess
- Put the following at the top of the file:
order deny,allow
deny from all
allow from 127.0.0.1
allow from IP1
allow from IP2
... - Save and quit the file
With the .htaccess file having the above contents at the top, your sites admin_interface page will now be locked down to IP1 and IP2
* 127.0.0.1 is the loopback address of your server and is usefull for testing and other functionality