Apache Trick: restricting access to single files by user and password

First, create an apache passwd file somewhere safe (but apache-readable) in the system, using htpasswd user; then create an .htaccess file in the directory to protect, with the directives

AuthName "restricted documents on _domain_"
AuthType Basic
AuthUserFile _location of passwd file_
<Files "_file to protect_">
Require valid-user
</Files>

you will also need to add AllowOverride AuthConfig in the relevant Directory section of your httpd.conf.

Oct 31, 2003

apache-password-protect (/webtricks)
2003-10-31, 13:00 [edit]


  Login:   Password:   [rss] [cc] [w3] [css]

© M. Vallisneri 2012 — last modified on 2010/01/29

Tantum in modicis, quantum in maximis