Central Iowa Railroad Herald

CIRR.COM

Web Hosting Support

Directory Protection


How to password protect a directory

Sometimes you may need to limit access to a particular directory on your web site, the best way to do this is with the built in functionality of the Apache web server. This is a method referred to as HTTP Basic Authentication (also known as htaccess).

There are two steps required to create password protection on a web site directory.

  1. Create the .htaccess file

    You must create a file called ".htaccess" in the directory you are trying to password protect.

    This file should contain the following:

    AuthUserFile home-directory/directory-to-protect/.htpasswd
    AuthName "My Directory"
    AuthType Basic

    <Limit GET POST>
    require valid-user
    </Limit>

  2. Create an .htpasswd file

    Next, you should create a file called ".htpasswd". This file should be a list of user-ids and passwords for users who will have access to the directory. The passwords will be encrypted.

    This file should look something like:

    bob:BR25shsluBBfw
    sam:3bg94.ItMzM1A

    In order to get the encrypted version of your password you can enter it below and hit submit:

    User Name:
    Password:

If you have any questions about our site, please send us mail.
Copyright 2000,2001 Central Iowa (Model) Railroad Contact Us Referral
Program
Support
$Id: password-protecting.html,v 1.3 2001/08/06 03:52:32 cirr Stable $ Terms of Service Privacy Information