|
Contributed by Chad Brandt
|
|
|
|
Thursday, 17 June 2004
Learn how to use .htaccess file to password protect all or parts of your website
|
1. create a .htaccess file. The .htaccess file should look something like this:
AuthUserFile /usr/local/www/.htpasswd AuthGroupFile /dev/null AuthName ByPassword AuthType Basic Require user chad
This file says that a user chad will authenticate against password file /usr/local/www/.htpasswd
Place this file in the directory you want to password protect. In my example I am securing the cgi-bin directory |
2. Create the password file
[root]# htpasswd -c /usr/local/www/.htpasswd chad
This will prompt you for a password for user chad and save your password to the file.
3. Edit your httpd.conf to deny from all. You can see the values I commented out and the values I put in the place
#AllowOverride None Options None AllowOverride AuthConfig #Order allow,deny Order deny,allow
4. Restart apache. When you attempt to access any file in the cgi-bin you will be prompted for your user name and password Only registered users can write comments. Please login or register. Powered by AkoComment 1.0 beta 2! |