Friday 9 December 2011

Create the .htaccesss file for your directory or subdirectory.

It is quite simple to generate .htaccess and .htpasswd files. Bofore that let's quickly look at the purpose of that file.

.htaccess files (or "distributed configuration files") provide a way to make configuration changes on a per-directory basis. A file, containing one or more configuration directives, is placed in a particular document directory, and the directives apply to that directory, and all subdirectories thereof.

Some Common usage of .htaccess file:

    This files are written into the Common Gateway Interface (CGI) script.

    Now you have to just follow the few simple steps to make it.
    1. Open your noteapad window.
    2. Save the file named as .htaccess in the directiory or subdirectory which you have to configure.
    3. Your blank .htaccess file have been made....!!!
    4. Now we can update that .htaccess file as per our need using CGI script. 
    Introduction to basic use of some CGI Rules and keywords:
    1. AuthUserFile /full-path-to-server-root/<name of your directiory or subdirectory>/.htpasswd
    2. .htpasswd file is an another file which contains your username and password in Encrypted form. Use to put authentication for your directiory or subdirectory.
    3. AuthGroupFile <path>
      Use to Controlling Web Page Access
    4. AuthName <name>
      This directive sets the name of the authorization realm for a directory. This realm is given to the client so that the user knows which username and password to send.
    5.  AuthType <type>
      type may be Basic or Digest. To implement the authentication you mut use AuthName first. 
    6. require valid-user
      It tell the server where to find the usernames and passwords and what authentication protocol to use. The server now knows that this resource is restricted to valid users.
    There was some basic about the CGI statements you can put it in your .htaccess file as per your need.