| Note:
you can password-protect a directory (folder) of web pages, but not individual
pages within a directory. If you don't want your whole web site restricted,
make a subdirectory (subfolder) and put the restricted pages there. Any
files within that folder, and
any folders within it, will be password-protected.
Example: 
Step 1
Log into the
cuip server using SSH. You will automatically be logged into your home
directory. You need to find the path to your home directory. Do this by
typing in pwd
and hitting the Enter key. The computer will respond with the path to
your home directory. Write this down, or highlight it and copy it. You
will need to use it twice in the following steps.
You can either stay
logged in (for step 3) or log out and log back in later.
Example :
Step 2
Make a text file using any text editor (Dreamweaver, WordPad on
the PC, SimpleText on
the Mac, even Microsoft Word if you save in text-only format). This file
must be called .htaccess—note
the period at the beginning of the file name—and
must contain the following text:
AuthType Basic
AuthName "test restriction"
AuthUserFile PathToYourHomeDirectory/webUsers
Require valid-user
The text in red
should be modified to your needs:
- The text that reads "test
restriction" above will be shown to the user in different
ways by different browsers. Replace with your own text, something like
"restricted files".
- The text that reads PathToYourHomeDirectory
should be replaced with your cuip home
directory. (This is
what you got from the pwd
command.) This indicates the directory in which the password
file will reside. Note: you can indicate a subdirectory within your
account, but don't use your www directory.
Use Dreamweaver or FTP to put this .htaccess
file into the directory on the server that you want to password-protect.
Step
3
If you logged out, log
into your cuip account using SSH. Type this in:
htpasswd -c PathToYourHomeDirectory/webUsers
loginname
note: this must be typed exactly, with spaces
only where indicated, capitalization as indicated. The text
in red should again be modified:
- replace
PathToYourHomeDirectory with your cuip home directory. (This
is what you got from the pwd command.)
- replace
loginname with the login
name you want your readers to use.
Press the Enter key.
You will be prompted to type in a password; this should
be the password that you want your users to use. You will have to enter
this twice.
(If
you want to have more than one
username and password, use the htpasswd command again but
without the -c option to add another username
htpasswd PathToYourHomeDirectory/webUsers
newLoginName
Again you will be prompted for a password and will have
to type it twice.)
At the end of this
step there will be
a new file in your home directory that contains the password information.
Do not rename or move this file!
Done!
The web pages in the directory that contains the .htacess
file are now password-protected!
|