Sep 19, 2018

How to Limit Access to Your Site Based on IP Address

You can limit access to your website so that only your IP address can access the site. 

Here are the steps to do that.
  1. Find out what your IP address is by visiting whatsmyip.org.
  2. Create a file called .htaccess in your website root directory.
  3. Place the text below in the file and replace the marker with your IP address.
order deny,allow
deny from all
allow from <your ip>
 
That should block anyone who isn’t from your IP address from accessing your web applications. Test it by using FTP or SSH to change the IP slightly and you should lose access to the website. Make sure you aren’t using a web based file manager, or you will block yourself when you do this test.

This is very useful when setting up WordPress and anything else knowing that no one else can abuse your setup scripts. During the initial set up, it is very vulunable.

To remove the access control, simply delete the above lines from your .htaccess file and access for everyone else will be restored.