Tag: htaccess linux lamp security

.htaccess: allow anyone from one IP but require password from everywhere else

If you want your linux-hosted site to be accessible by anyone coming from a particular IP address, as say from within a corporate firewall, but also accessible from anywhere else as long as they authenticate with username and password, use this formula in the .htaccess file for the directory:

#this section may need to be modified to suit your password authentication setup:
AuthUserFile "/home/pathTo/.htpasswds/directory_name/passwd"
AuthType Basic
AuthName "webroot"
require valid-user
# allow users from inside firewall
Allow from 111.222.33
Satisfy Any
Continue reading