linux poison RSS
linux poison Email

HowTo use .htaccess file for Apache authentication

1. Create the directory you want to password protect (example: nikesh)

2. Create a file /var/www/html/nikesh/.htaccess in that director that looks something like this:

AuthName “Add your login message here.”
AuthType Basic
AuthUserFile /etc/apache/.htpasswd
AuthGroupFile /dev/null
require user name-of-user

In this case the “name-of-user” is the login name you wish to use for accessing the web site.

3. In apache configuration file, change the AllowOverride to AuthConfig for the directory that you wan to protect with password.


AllowOverride AuthConfig

3. Create the password file /etc/apache/.htpasswd using the program htpasswd:

# htpasswd -c .htpasswd name-of-user

Read Man page: htpasswd



0 comments:

Post a Comment

Related Posts with Thumbnails