Site's Administration : Password protecting directories
Contents ]
Dr Benton

Customising the .htaccess File

To make the access restriction work, you need to adapt the text of the .htaccess file:

  • AuthUserFile: This is the file system path for the password file that you will create later on in this workshop.

  • It is essential that you start with /data/members/free/tripod/uk/ followed by the first three letters of the username separated by a slash (example: /o/l/i/ for the user id oliviari). Then add /htdocs/ and the access path of the protected directory.

The access to the directory must be specified as a relative path, i.e. by leaving out the domain name: for instance, /id/directory/, not http://www.domain.com/id/directory/).

  • AuthGroupFile: Keep this line as it is!

  • AuthName: specify the name you want to assign to the protected area. In our example, you will see the following dialog box when you attempt to access a page stored in the directory called /secret/:



  • Figure 1: Who goes there?

  • AuthType: Do not change this line!

  • <Limit GET> : Idem.

  • require user : defines the username which must be entered in the id field when the previous dialog box appears:

  • - One username: require user userid

    - Multiple usernames: require user userid1 userid2 userid3 ... (each user must be separated by a space)

    - All usernames from the .htpasswd file without explicitly entering their names: require valid-user

  • </Limit>: This line cannot be changed.

Then store the .htaccess file in the directory to be protected.

The .htaccess file may not be stored under the root of your account. It must be located in a folder that you create.

Now all you have to do is to append each user's password to this access file.