.htaccess file (exactly as shown with noted variations and note the file name must include the .)
AuthName MySecurity (some chosen text with no spaces or special characters)
AuthUserFile /home/std/ab12cd/public_html/myfile (ab12cd should be your id & myfile should be your chosen password file name)
- Creating this file with world/other read permission causes the web server to show a password dialog before displaying web pages within public_html.
- To ensure world read
permission you could issue the command chmod o=r .htaccess
- The file titled myfile (your name might be different) is the file of usernames and passwords allowed to view web pages.
- This file must also have world/other read permission.
- Creating the file and adding users and password is described below.
- In order to prepare the password file you will need to login to sandcastle (see lab 1) and position yourself to the public_html directory.
- To see the options for the htpasswd command simply type htpasswd and press return.
- To create a new password file type htpasswd -c myfilename firstusername.
- You will be prompted for the password twice and after having done so the file is created with one user entry.
- You can add other users with htpasswd myfilename someotherusername. Do not supply -c for other user entries as this is only needed the first time.
- You can view the contents of the file with the cat command, such as cat myfilename. This will display the users and the encrypted version of the passwords.
- You can change the password of an existing user with htpasswd myfilename useralreadyinthefile and will be prompted for the new password.
- Note that the password file name will be referenced in the AuthUserFile line of the .htaccess file as described above.
- The password file must also have world/other read permission.
Computer Science Department | COSC