|
How to setup password protected web pages
There are few files you need to create in order to setup password protection, a
.htaccess file in the directory you want to protect and password and group (optional) files. The first line of the .htaccess states where the password file is located. Here is a simple .htaccess file:
AuthUserFile /home/staff/user/pwd/.htpasswd
AuthName "myfriends"
AuthType Basic
require user jack
require user jill
require user fred
This files will allow only the users jack, jill and fred to access the page. If you have many users you may want to set up a group file as well. Here's an example of a .htaccess using a group file:
AuthUserFile /home/staff/user/pwd/.htpasswd
AuthGroupFile /home/staff/user/.htgroup
AuthName "myfriends"
AuthType Basic
require group friends
Now to setup the password and the group file. Both files must be world readable. You also do not want to put these files in the WWW (or WWWS) directory where they
can be downloaded. In the examples I set up a directory name "pwd" to store
these files. Use the command htpasswd to create and add to the password file.
Here's how to create the directory and setup a password file:
chemistry% pwd
/home/staff/user
chemistry% mkdir pwd
chemistry% chmod a+x pwd
chemistry% cd pwd
chemistry% htpasswd -c .htpasswd jack
Adding password for jack.
New password:
Re-type new password:
chemistry% htpasswd .htpasswd jill
Adding password for jill.
New password:
Re-type new password:
chemistry% chmod a+r .htpasswd
You only use the -c option when you create the password file. The group file
is a simple format like this:
friends: jack,jill,fred
enemies: peter,paul,mary
|