I was recently wanting to password protect my development server running Apache2 using .htaccess, but I was getting annoyed by having to enter a password while I’m at the office, or having my boss enter a password when I’m showing him what I’m working on. I recently found how to require password protection for IP addresses outside of our local network. I knew I could allow or deny certain IP address but I didn’t know I could permit access by IP or user authentication. This is my .htaccess file. You’ll have to setup your own .htpasswd file for authentication.
AuthType BasicAuthName “Development Site”AuthUserFile /path/to/.htpasswdRequire valid-userDeny from allAllow from 192.168.1Satisfy Any