Password-protecting Web Folders I

Password protecting your web folders / directories is easy - if you know how. When I first wanted to password protect some of my web folders, I understood so little and it didn't help that so many tutorials out there showed me different ways to do effectively, the same thing.

Well, the method I use now is very straight-forward and I think will eliminate the need to chmod files and such (which I can't stand to do). Also, you need to be certain that your web server is the Apache Web Server.

Let's assume a few things first:

Your WWW root is:
path: /home/username/public_html/
and your password protected folder is going to be:
path: /home/username/public_html/articles/secret/

So basically when a reader types http://www.example.com/articles/secret/ you want it to prompt for a username and password.

.HTPASSWD folder

Create a .htpasswd folder outside your web root:
path: /home/username/.htpasswd/

Now create the 2 folders that match the structure of your password protected folder of your web:
path: /home/username/.htpasswd/articles/secret/

Inside this folder create a passwd file. Yes, that's right, just name it passwd - no extensions!

e.g.
path: /home/username/.htpasswd/articles/secret/passwd

PASSWD file

This file will contain your username(s) and encrypted password(s) and will usually look like this:

code:
christopher:En7Cr9pT2Ed/u

To create your passwd file, use the following .htpasswd generator to generate a username / encrypted password pair for yourself

Fill-in the form below.

Username
Password

Now, the second part of this article describes the other file we need to create to complete our password-protected web folder - .htaccess. Go to...

Part II

TOP

Do you find it easy to navigate through this site?

 Yes

 No

 Where am I?