htaccess



To password protect a directory (and all subdirectories of it) on your Web site, you can use htaccess. The way it works is when people hit your protected URL, a dialogue box pops up requesting a valid-user and password. Valid-users and passwords are whatever you set them to be. You can have valid-users and passwords for individuals or groups of people.

To set it up, create a file named .htaccess (the period before "htaccess" is vital) and put it in the directory you want protected.

The content of .htaccess must be the text below (cut & paste). Replace the bolded "youusername/dir/" with your Cyborganic username and directory path of where you are placing the .htaccess file. Replace the bolded "Name of Secret Area" with whatever text you want your users to see in the dialogue box that requests their name and password.

AuthUserFile /www/Cyborganic/people/yourusername/dir/.htpasswd
AuthGroupFile /dev/null
AuthName Name of Secret Area
AuthType Basic

<Limit GET POST>
require valid-user
</Limit>
Once you have that in place (be sure to save and upload as TEXT only), you need to set valid-users and passwords. To do so, telnet to staging.cyborganic.net. Go to the directory you put the .htaccess in. If you type

htpasswd

you will see instructions for setting passwords:

Usage: htpasswd [-c] passwordfile username
The -c flag creates a new file.

In this instance, "username" is not your Cyborganic username, but rather the valid-user name you wish to allow access to. The "passwordfile" should be .htpasswd (period before "htpasswd" is vital).

So if I want to allow my friend Jake (or a group known as "Jake" for that matter) to have password access this area, I would type:

htpasswd -c .htpasswd Jake

I will then be prompted to enter Jake's password twice. You can repeat the htpasswd command for as many valid-users as you would like to set. When you are finished, be sure to end your telnet session by logging out (type exit or logout).