Wednesday, September 17, 2008

htpasswd for particular folder

AuthUserFile d:/xampp/htdocs/.htpasswd
AuthGroupFile /
AuthName "Restricted Access"
AuthType Basic
<limit GET>
 require valid-user
</Limit>

1 comment:

shanmuga said...

more information:
http://tools.dynamicdrive.com/password/

----------
Generated Code

Step 1: Insert the below code into your .htaccess file, and upload this file to the directory you wish to protect (or which the files you wish to protect is under):
.htaccess:
AuthName "Restricted Area" AuthType Basic AuthUserFile /home/mysite/.htpasswd AuthGroupFile /dev/null require valid-user

Step 2: Save the below code into a file called .htpasswd, and upload this file to the location as specified in the "AuthUserFile" line above. It contains your username(s) and encrypted password(s). Important: .htpasswd should be put in a non public folder, such as directly above your public HTML folder, to prevent visitors from viewing this file in the browser.
.htpasswd:
shanmuga:uz2.nRNvEdMwQ

So to recap:

1. Upload ".htpasswd" to the root or a non publically accessible directory on your server.
2. Upload ".htaccess" to the directory you wish to protect, and inside this file, verify that the server path to the .htpasswd file above is valid:

AuthUserFile /home/mysite/.htpasswd

If you've uploaded the ".htpasswd" file to simply the same directory as your ".htaccess" file (less secure than root directory), then the path would look something like this instead:

AuthUserFile /home/mysite/public_html/mydirectory/.htpasswd

And you're done! Be sure that you've uploaded both files in ASCII, and not binary format.

Post a Comment