Controlling Web Page Access With HTAccess

from  http://www.mcs.kent.edu/system/web_help/htaccess/introduction.html


Creating a .htaccess file

The .htaccess file should be created in the directory you which to protect. This could be your entire public_html directory, or a subdirectory of your public_html directory. Once a .htaccess file has been placed in a directory, everything in that directory (including all subdirectories and their contents) will be protected.

The .htaccess file contains the instructions for determining who is allowed to access the directory. There are two sections of the .htaccess file:

  1. The first section of .htaccess must contain 4 lines:

  2.   AuthUserFile {path to .htpasswd file}
    AuthGroupFile {path to .htgroup file}
    AuthName {title for dialog box}
    AuthType Basic
  3. The second section must contain 3 parts:

  4.   <Limit GET>
    {access instruction to be executed}
    </Limit>
Note: If your title on the AuthName line is longer than one word, the title must be enclosed in double quotes.
Example