Have you ever wanted to password protect a folder on your server? For example, suppose you had a Word doc that you wanted to share with the folks you work with, but wanted to keep away from other prying eyes. One way to do this is to use the .htaccess mechanism. In a nutshell, you’d build a list of usernames and encrypted passwords in a file named .htpasswd, then put a link to that file in another file named .htaccess. You put the .htaccess file in the directory you want to protect and, voilà, anyone who steers their browser to the specified directory will have to login using one of the username/password pairs before they are able to access the protected director.
Best way to show you what I mean here is with an example.
Click on this link.
You should be prompted for a username and password. Use a username of “friendodave” and a password of “secret”. All without the quotes of course.
When you get in, you should see a link to a secret picture. Did it work? Cool! Leave me a comment either way, just to let me know if it worked for you.
Want to learn more? This is a great tutorial on using .htaccess. As you can see, there’s a lot more to this mechanism than simply password protecting a directory. Pretty powerful stuff.