Basic Password Protection for Apache Webpage

This is the bare bones basics to protect a web page or series of pages on an Apache web server.

.htaccess file

AuthName "SectionName"
AuthType Basic
AuthUserFile /full/path/to/.htpasswd
Require valid-user

Replace SectionName with the name of what you are protecting (in and below the directory that you are putting the .htaccess file in. Example: My Web Site

Replace /full/path/to/.htpassword with the actual full path to the .htpassword file you created.

.htpassword file

username:encryptedPassword

Replace encryptedPassword with your choice of password encrypted with the htpasswd program that came with Apache. Use man htpassword for instructions.

You can then access the page with the normal address…in which case it will ask for the username and password, or you can use this:

http://username:password@website.com/page

Be Sociable, Share!