How to Password Protect a Directory
A password-protected directory protects that directory and all directories below it. To password-protect a directory(ies) in your AFS Website, log into afs1.njit.edu - afs36.njit.edu and run the command:
Notes:
Alternatively, you can use the procedure below to password-protect the entire contents of a directory in your public_html folder. (The directory in the example below is titled "DIR")/usr/ucs/bin/setup.htaccess
cd DIR
-
htpasswd -c .htpasswd <username>
(e.g., htpasswd -c .htpasswd cis101)
(htpasswd requests a password for cis101) -
Use a text editor to create the file ".htaccess" (without the quotes), with the following lines:
AuthName <GroupName>
AuthType Basic
AuthUserFile <path-to-.htpasswd>
AuthGroupFile /dev/null
<Limit GET>
require valid-user
</Limit>
Notes:
- <GroupName> can be any name, e.g., CIS101; it is not the same as username.
- Groupname is displayed when the Password box pops up, and is used only as a name for the directory being protected.
- If <GroupName> is more than one word, enclose it in double quotes ( " )
-
<path-to-.htpasswd> is the full path to the location of the ".htpasswd" file for this directory. If DIR is ~abc1234/public_html, then <path-to-.htpasswd> is:
/afs/cad/u/a/b/abc1234/public_html/.htpasswd


Information Services and Technology