Using the .htaccess File to Allow Two Computers Access

In order to control access to parts of a website one can use a .htaccess file to restrict the IP addresses which are allowed to view files in a folder. I have two computers which I generally use to access the admin functions of my website, so I wanted to set up the .htaccess file so that either computer could log into the WP-Admin functionality. After looking through various online suggestions, I figured I should be able to do something like this to allow either IP address:

Order Deny,Allow
Deny from All
Allow from xx.xx.xx.xx
Allow from yy.yy.yy.yy

But when I put this in my .htaccess file, when I tried to load the website I just got an error saying that Apache was misconfigured. If you see anything wrong with the code above, I would love to hear why it does not work, since every site I looked at seemed to suggest this should work for what I am trying to do.

The setting that I have been using, and has been working, is like this:

Require IP xx.xx.xx.xx

But when I use this, each time I switch computers I have to ssh into the host and manually alter three different .htaccess files to use the correct IP address before I can log into WP-Admin, which is annoyingly tedious. So I did some more digging and came up with some more technical documentation, where I found the option to use this form:

<RequireAny>
Require IP xx.xx.xx.xx
Require IP yy.yy.yy.yy
</RequireAny>

Which lets either computer access the folder.

Tags: ,

Leave a Reply