Saturday, February 26, 2005

Htaccess :Restict http access to pages

Htaccess is a method that helps you share your http pages in a rescticted manner, allowing access only after authentication. For example to restrict access some directory in ~/public_html/example_dir create a ".htaccess" file in that directory with lines similar to those given below
--------
AuthType Basic
AuthName RelmName
AuthUserFile path_to_htpasswd_file_here_say_ /extra/.htpasswd
Require user list_of_usr_names_here
------------

This file says that we consult /extra/.htpasswd file to get the usr passwd pair for authentication, where the only user allowed to access are the ones listed in Require field.

The .htpasswd file need be accessible to your http-user ( apache/nobody ) for reading . Good not to have it readable by others.htpasswd utility can be used to set passwds for users ( these need not exist on the system)
Have a look at this link http://httpd.apache.org/docs/howto/auth.html#intro

0 Comments:

Post a Comment

<< Home