Password Protect Apache Directories

This page describes how to password protect a directory on an apache web server. Only a user with the correct username and password will be able to view the contents of that particular folder. You can decide what the username and password is.

Password Protected Folders

As you can see above there are 2 files of interest:

  • .htaccess
  • .htpasswd

.htpasswd

This file contains something like..

username:|PaSSwoRD

The username is the literal username and the password is an encrypted version of the password

.htaccess

This file contains something like..

 
AuthName "Please Login"
AuthType Basic
AuthUserFile /home/mywebserver/.htpasswd
Require valid-user

The first line dictates what the prompt will be

Comments For This Page

No comments yet, be the first !

Add your own comment below and let others know what you think: