Password Protecting Directories

This is super useful if you want to make a 'members only' section, or a directory with private stuff for you!!!

First of all, you're going to need a .htpasswd file. You can create one the same way you created your .htaccess file. (Click here to refresh your memory if you need to.) Upload this file one directory ABOVE all your files, or at least somewhere away from all your website files. if you're hosted or have a domain, you'll probably know what I mean: You know the folder where you upload all your files so that people can see them? That's in another folder, right? Upload them to that one. But you're also going to need to know your absolute path to it, which on most cases will be /home/YOURUSERNAME/.htpasswd but if you're not sure, ask your host. Just, make sure to remember that path.

Next, you're going to need to make up your user name and password. You can have multiple ones of these, just make sure it follows the form:
username:password


It's probably a good idea to encript it, so use this tool to encript it. And if my tutorial doesn't really make sence, it also helps create the files needed ^__^.

There. Now that you have your .htpasswd file made, let's make your .htaccess file!! This file's going to be separate from all your other .htaccess files, so create a new one. On it, put this:

AuthName "Restricted Area"
AuthType Basic
AuthUserFile YOUR ABSOLUTE PATH
AuthGroupFile /dev/null
require valid-user


You see where it says YOUR ABSOLUTE PATH? Replace that with the path mentioned above that reflects where your .htpasswd file is. Now upload this to the directory you want to be password protected, and there! You're all done!! Now, you'll notice in my navigation under 'Tagteam' there's a link that say's 'Admin'? That link's password protected. If you want to see what the login looks like, feel free to check it out!! Hacking it won't do all that good, because it's just a bunch of links I need to remember and notes to myself. But, there you go! A password protected folder! And you can have multiple users, as well. On your .htpasswd file, put each username:password on a separate line, and done!

I'm sorry if this tutorial wasn't as comprehensive as my others. It was a really difficult one for me to explain. If you really want to password protect something, but you didn't find this helpful at all, click here for a much better tutorial.

Tutorial adapted from Sillymahala.com. I did not steal this, since I own Sillymahala AND this site.