PDA

View Full Version : .htaccess Password Protection


MadMax
2005-06-12, 03:42 PM
I've got a couple directories for work in progress that I need an easy way to password protect. It would just be for a single username/password. I'm thinking .htaccess is probably the easiest way to go about it, but I'm not sure how to implement this. Any help out there?

TIA

cd34
2005-06-12, 03:57 PM
.htaccess (adjusting the path to fit your area)

AuthUserFile /var/www/domain.com/admin/.htpasswd
AuthName "Members Only"
AuthType Basic

require valid-user


If you have shell access:

htpasswd -c /var/www/domain.com/admin/.htpasswd username

it will then prompt you for a password & verification

If you don't have shell, you can run this (test being of course the password you want to use):


<?php
print crypt('test','ab');
?>


And take the output from that and upload a file called .htpasswd that contains:

username:outputfromabove

Cleo
2005-06-12, 04:15 PM
Here is a page that will generate the encrypted passwords without using a shell
http://www.e2.u-net.com/htaccess/make.htm