This is done with two files, .htaccess and .htpassword.
First, create (or upload) a file called .htaccess to the web directory which you would like to password protect. The .htaccess file will look something like this:
Code:
AuthType Basic
AuthName "Michelle's Web Site"
AuthUserFile /usr/local/www/data/michelle.com/.htpasswd
Require user michelle
You will need to set AuthUserFile to the location of your .htpassword file.
In this file, your username is "michelle."
Next, create (or upload) a file called .htpassword to the same directory. The .htpassword file will look something like this:
Code:
michelle:yL05LynwCLoxQ
Once these two files are in place, you are ready to login.
This is where things get tricky.
You may be asking "What the heck is yL05LynwCLoxQ?"
yL05LynwCLoxQ is the (sort of)
encrypted version of your password. Your actual password, in this example, is "r0ckZ".
Most tutorials tell you to run the htpassword command to create an encrypted version of your password. Of course, with some Unix hosting setups -- you don't have access to a Unix shell to run the htpassword command! The solution is to use a web-based password generator such as the
Showcase password generator.
A much more in-depth explanation of Apache user authentication can be found at Apache.org under
Authentication, Authorization, and Access Control.