What is Password Protection There are many websites that cause a box to pop up asking you for a username and password. If you don't know the password, you can't enter the site. This provides some security to your Web pages and gives you the chance to choose who you want to allow to see and read your Web pages. There are many ways to password protect your Web pages, from PHP, to JavaScript, to HTAccess (on the Web server). When Should You Password Protect Pages? With HTAccess, you can password protect any page or directory on your Web server. You can even protect the entire website if you want to. HTAccess is the most secure method of password protection, as it relies on the Web server, so the valid usernames and passwords are never shared with the Web browser or stored in the HTML like they can be with other scripts. People use password protection: * Hiding new versions of your website from the public until they are ready to launch. * Protecting private sections of your website so that only people you know and trust can read them. * Providing paid content to your customers and only allowing access via a password. * Creating a private forum for select readers. It's Easy to Password Protect Your Web Pages You need to do two things: 1. Create a password file to store the usernames and passwords that will have access to the directory. 2. Create an htaccess file in the directory to be password protected. Create the Password File 1. Open a new text file called .htpasswd Note the period at the beginning of the filename. 2. Use a password encryption program to create your passwords. Paste the lines into your .htpasswd file and save the file. You will have one line for every username that requires access. 3. Upload the .htpasswd file to a directory on your Web server that is not live on the Web. In other words, you should not be able to go to YOUR_URL/.htpasswd - it should be in a home directory or other location that is secure. Create the htaccess File 1. Open a text file called .htaccess Note the period at the beginning of the filename. More Here : Giftmeideas.c-0-m
To generate the encoded passwords for .htpasswd files you can use online tools. Several are available online. Just make sure that the generation is done using javascript, so the passwords are generated on your machine and don't travel over the internet. Check the one from Joe’s Webtools: http://www.joeswebtools.com/security/htpasswd-generator/. It's easy to use and do the job.