The best way to password protect directory on website is with
.htpasswd and
.htaccessHere is how to do this.
1. Choose a user name and password. Now, you need to encrypt password to use for .htpasswd
You can use any of these tools to encrypt password:
http://www.4webhelp.net/us/password.phphttp://www.tools.dynamicdrive.com/passwordFor example, if you choose user name:
demo and password:
Demo123,
the result will be line like this:
demo:93EiPZZQoIKUA2. Create file named .htpasswd and put there just this line with user name and encoded password.
3. Upload .htpasswd to server, preferable to directory that is not accessible from web. For example: /home/mydir/
4. Create .htaccess with the following content:
.htaccess
AuthUserFile /home/mydir/.htpasswd
AuthType Basic
AuthName "Enter your password"
Require valid-user5. And finally, upload .htaccess to directory you want to password protect.
This will protect the entire directory (all files and subdirectories). If you wish to protect entire website, you need to place .htaccess to web root directory.
If you need to protect certain files (not entire directory) you need to put to your .htaccess the following code:
.htaccess
AuthUserFile /home/mydir/.htpasswd
AuthType Basic
AuthName "Enter your password"
<Files "memberonly.html">
Require valid-user
</Files>