AlpineWeb Home
Search: For:   ~ Advanced Search  
  Support Home     Documentation     Knowledgebase     Help Desk     Blog 
Support Home > VPS v1 > Webserver > Configuration > Monday, October 06, 2008

Creating Password Protected Directories


What you are trying to do is called "user authentication". The best place to learn about user authentication is from the source (NCSA). They have a very easy to understand tutorial at the following URL:
http://hoohoo.ncsa.uiuc.edu/docs/tutorials/user.html
You should be aware of one subtle difference with the Virtual Server System-- when you set up your .htaccess files, you will specify the AuthUserFile or AuthGroupFile with respect to your home directory.

However, when you set up your .htpasswd files with the htpasswd command you will need to prepend /usr/home/[login_name] to the directory specification.
NOTE: If you will be authenticating thousands of users, or more, you should consider DBM User Authentication which works much faster and more efficiently with a larger number of users.
For example, let's say you have a subdirectory billy in your ~/www/htdocs directory. You would like to restrict access to this directory. This can be done by first creating a .htaccess file in the billy subdirectory such as the following:
AuthUserFile /etc/.htpasswd
AuthGroupFile /dev/null
AuthName Bill's Restaurant
AuthType Basic

<Limit GET>
require user William
</Limit>
This .htaccess file will only allow one user, "William", to access the directory billy; provided the correct password is given. The password is to be stored in the /etc/.htpasswd file (see the AuthUserFile declaration in the .htaccess file above).

To set up the password for "William" issue the following command:
% htpasswd -c /usr/home/[login]/etc/.htpasswd William
Use the htpasswd command without the -c flag to add additional users; e.g.:
% htpasswd /usr/home/[login]/etc/.htpasswd peanuts
% htpasswd /usr/home/[login]/etc/.htpasswd almonds
% htpasswd /usr/home/[login]/etc/.htpasswd walnuts
NOTE: To run the htpasswd command correctly, you will need to prepend the /usr/home/[login_name] path to the password file specification (substitute your login name for [login_name]). You do not need to use the /usr/home/[login_name] path in the .htaccess file.


Technical Support
° Getting Started Guide
  FreeBSD
° VPS v1 Help
° VPS v2/3 Help
° MPS v2/3 Help
  DNS
° Domain Name Service
° Domain Registration
   
° Help Desk
° Knowledgebase
° Support Policies
° Disclaimer

° AlpineWeb Home
° Compare Hosting Plans
° Network Topology

° Rates & Fees
° Order Center


  SEE ALSO
· Installing User Authentication
· About the Apache Web Server
· Choosing Passwords for Your Virtual Server Accounts


  Home | Site Map | Customer Backroom Copyright  ©  1997-2008  AlpineWeb Design