Apache: password proctect your staging instances but allow your office IP

A common (good) practice is to protect your staging/dev instances with a password. It can be annoying with old browsers that don’t store passwords.

To allow your office IP to connect without entering a password, just add the following lines to your virtualhost config:

AuthName "Protected"
AuthUserFile /path/to/.htpasswd
AuthType Basic
Satisfy Any
<Limit GET POST>
    Order Deny,Allow
    Deny from all
    Allow from 123.123.123.123
    Allow from 123.123.123.124
    Require valid-user
</Limit>
  • replace 123.123.123.123 with your IPs.

See also Apache HTTP Server Tutorial: .htaccess files