
Robert K. Moniot
September 16, 2001
<Directory /home/webber/public_html>
AllowOverride AuthConfig
</Directory>
where /home/webber is replaced by your home directory.
Without this, the usual default is AllowOverride None, which
means that .htaccess files are ignored. The above stanza
allows .htaccess control in all subdirectories of the
specified Directory.
Let us name this directory http-etc by analogy to the Unix
/etc directory where the system passwd and group
files reside. Place it in your home directory (not in public_html) so that it is
outside URL space. Give it permission 701 = rwx-----x
meaning you the owner can do anything, and the web server, running
as the ordinary user apache, can access the directory but
cannot list it (so it must know the file names in
advance).1
rw-r--r--. This file can be created empty
by the touch command, or created with one initial entry by using
the -c option when you run the htpasswd command the
first time.
htpasswd http-etc/htpasswd guest
In this example, the htpasswd program will prompt you for the password for user guest. After you type the password, you will have to re-type it for verification. The format of the password file is like this:
guest:IA22a/FU48faw
janeuser:kyxFwALyFbsPw
joeuser:rjyJsqbtXCvXo
The gibberish after each user's name is the encrypted password.
The plaintext passwords are not stored, for obvious security
reasons. You cannot edit this file to change the passwords, unless
you are the kind of
person the NSA is very interested in hiring. The only way to
update it is with the htpasswd program.
guest: guest
users: janeuser joeuser
AuthType Basic
AuthName "Restricted Directory"
AuthUserFile /home/webber/http-etc/htpasswd
AuthGroupFile /home/webber/http-etc/htgroup
Require group users guest
Alternatively the require directive can say:
Require user guest joeuser
or
Require valid-user