How to Password-Protect a Web Subdirectory

The following instructions describe how to password-protect a subdirectory in your Web space.

In this example, you'll learn how to password-protect a directory in your personal Web space for three names (Peggy, Danette, and Bill) who will all have the password secrets (use capitalization where indicated). To see this example, see http://www.personal.psu.edu/mcr/party/.

To make this work, you will create three small text files that will go into a directory in your personal www directory.

Step 1: Create the directory you wish to password-protect.

Step 2: Create your .htaccess file.

Step 3: Create your .htpasswd file.

Step 4: Create your .htgroup file.

Step 5: Modify the Access Control List (ACL) for the "party" directory.

Testing and Troubleshooting

Now try to access your directory named "party" on the Web. If everything is set up correctly, your browser should prompt you for a username and password. You should not be able to access the directory unless you enter one of the user name - password combination you entered when creating the .htpasswd file. In our case one of the user names: Peggy, Danette, or Bill and the password secrets.

Remember, the Personal Web server is case-sensitive. If you have trouble, check to make sure you're using the correct case.

Make sure you name the three files correctly. They must be named as follows or it won't work.

.htaccess

.htpasswd

.htgroup

If you get a Internal Server Error" message, chances are you did not upload the files using the "ASCII" (for PC's) or "Text" (for MACs) mode. Again upload the files, this time using the right mode as specified in the previous line.

Frequently asked questions and answers pertaining to CAC Web service are available at the following URL: http://www.personal.psu.edu/faq/cacweb.html