Wednesday, December 22, 2010

Password Protect Directories using HTACCESS

This tutorial will explain how to password protect your directories using .HTACCESS and .HTPASSWD
You may want to protect your web directories from listing content publicly if they contain your private content. This is the easiest way to protect your directory using password authentication.

First of all, create a new text file and rename it to .HTPASSWD and enter this text


Next, create another text file and rename it to .HTACCESS and enter this text

AuthUserFile /home/user/domain/path/folder/.htpasswd
AuthType Basic
AuthName “Login Details”
Require valid-user

Upload both the .HTACCESS and .HTPASSWD files to the directory you want to password protect. Now if you try to access that directory, it will prompt you for a username and password.

You can add more users to the .HTPASSWD file if you want to. If you want to use the same .HTPASSWD file for protecting another directory, you can just reference it again in your .HTACCESS.

No comments:

Post a Comment