HTACCESS
Password Protect a Directory
If your web site address begins with http://www.gmu.edu, HTACCESS allows you to password protect a directory. Follow the instructions below to enable HTACCESS:
- Logon to your osf1 account
Type:
cd /usr/local/htdocs/your_directory_path
- If you have a directory already created for the page(s) that you want to protect, change into that directory:
cd your_directory_path
- If not, type:
mkdir your_directory_path
- Move to the new directory:
cd your_directory_path
- Create a file called ".htaccess" in your_directory_path
To do this type:
pico .htaccess
-
Type the following information just as it appears:
(directory means your_directory_path)
AuthUserFile /usr/local/htdocs/your_directory/directory/.htpasswd
AuthGroupFile /dev/null
AuthName Your_Site_Name
AuthType Basic
<Limit GET>
require user JohnSmith
</Limit>
- Save the above file, and at your command prompt type:
/usr/local/apache/bin/htpasswd -c   .htpasswd JohnSmithReplace JohnSmith with your first username as it appeared in the previous step-it is case sensitive!!!
- Now type each of the below as separate commands:

- To add more users, type:
pico .htaccess
add another line under require user JohnSmith with a different username i.e. require user JaneSmith
Example
< Limit GET >
require user JohnSmith
require user JaneSmith
require user JoeSmith
< /Limit >
Save the .htaccess file
- At your prompt type:
/usr/local/apache/bin/htpasswd .htpasswd JaneSmith
Create a password and remember it! Repeat this step for each new username replacing JaneSmith with the necessary username.
(**Note the above command is different than what you've typed before. There is no -c; If you use -c it will erase all previous usernames/passwords and create a new file)

