Password protected web pages can easily be achieved using a process  called User Authentication. With User Authentication it is possible to  set up a directory which once accessed will require the visitor to fill  in a password form,specifying their Username and associated Password.  There is no back door to get round the password dialogue, if any file is  called that is within your directory that has been protected by User  Authentication the visitor will need information provided by you (a  UserName and Password) to access the particular page they are after. 
 
Password protected web pages require two files to be created a  .htaccess (Authentication File) file and a htpasswd (Password File) both  of which are shown below. 
 
Authentication File 
First you need to write your .htaccessscript. Copy the script  between the lines below and edit to suit your needs. Explanations of  each line also follow below. 
 
AuthType Basic 
AuthName Your_Site_Name 
AuthUserFile /usr/home/username/password_file 
 
require valid-user 
 
 
EACH LINE IN DETAIL 
AuthType Basic - This line requires no editing and should be left as it is. 
AuthName - This can be whatever you want it to be, for instance the name of your web site 
AuthUserFile - This must be the complete path to the file containing  the usernames and corresponding passwords. This will be mentioned  later. 
require user - This is where you specify the users that you want to have 
access to your protected directory. For example require user Fred Sally John George 
Next save the above as htaccess.htm and upload via FTP to the  directory you wish to protect. Be sure to upload in ASCII mode. Once  htaccess.htm is in your chosen directory rename it to .htaccess 
 
You now need to Telnet to your web space. Log in with your username and password. 
 
After you have logged in change directory to the directory that contains your .htaccess file ( cd yourdirectory ) 
 
Now type chmod 755 .htaccess 
This will change the Unix file permissions of the file, enabling it to be used on your web site. 
Password File 
 
Still at the Unix Prompt of your chosen directory type: 
/var/www/bin/htpasswd -c passwordfile username 
 
If you had named your passwordfile SomeFiles and your username was Fred you would type: 
/var/www/bin/htpasswd -c SomeFiles Fred 
 
Note: The password file name used in creating the password file as  shown above is the same password_file that is mentioned when you created 
your .htaccess file 
You will now be prompted to enter a password for the username  specified and then re-enter the information to confirm your entries. 
Remember that Unix is case sensitive so you must re-type exactly. 
 
Finally, enter addtional UserName/Passwords to your htpasswd file as shown below: 
 
/var/www/bin/htpasswd passwordfile UserName 
 
Note that the [ -c ] part of the original line is not included as this is purely for creating new password files. 
 
Also note that additional users specified in your htpasswd file must also be specified in your .htaccess file.
- 0 Users Found This Useful
 
