Overview: You can protect parts of your website from public viewing by requiring users to first enter a correct username and password before accessing them. This allows you to offer information and access for sale, as well as to distribute sensitive or confidential information to only certain people.
- Before Beginning
-
Group the pages you wish to protect into a single directory (folder) in your
www
directory. -
Follow these steps
- Login to your Netmar account through telnet (see Question 1.9)
-
Type:
htpasswd -c passwords.txt username
and press ENTER. Replaceusername
with a 3-8 character username you wish to create for a user to access your restricted area. Create and enter a password for that user. You will be asked to type it twice without seeing it, so type carefully. -
If you wish to add additional users, type:
htpasswd passwords.txt username
and press ENTER. Replaceusername
with a 3-8 character username you wish to create for a user to access your restricted area. Create and enter a password for that user. You will be asked to type it twice without seeing it, so type carefully. You should omit the-c
from the command this time and any other time AFTER the first user is added to the password list. -
Type:
cd www/somedir
and press ENTER. Replacesomedir
with the name of the folder where your restricted files reside. -
Type:
restrict "My Protected Area" ~/passwords.txt
and press ENTER. Replace"My Protected Area"
with some text you would like to appear on the login window users will see. - Optionally, you may want to create a code 401 error document so that users who enter an incorrect password will see your own custom message instead of the system default. See Question 2.9 for details.