Tuesday, February 24, 2009

To protect a directory with .htaccess in Fedora

A folder or directory of the public documents can be protected to prevent unauthorized visitors from seeing its contents using "HTTP authentication"

Create a file named .htaccess in the directory you want to protect and put following into file:

AuthType Basic
AuthName "Secure Area"
AuthUserFile /etc/httpd/conf/htpasswdfile
Require valid-user

Save the file and exit.
Now create the htpasswd file at given location.

cd /etc/httpd/conf

htpasswd -c htpasswdfile admin

Here one user 'admin' and password file 'htpasswdfile' is being created with the command 'htpasswd'
It will prompt for password (2 times), supply the password.

## (Some how apache, the web server user is not able to read the password file if you place the file in /root and /home/ folder so keep the file in the location where the httpd.conf file is)

## Make sure AllowOverride is set to All in the httpd.conf file

No comments:

Whats new in Ajuby 0.5