Password Protect a Folder May 23rd, 2013

  • Create .htaccess and .htpasswd files in the folder
  • One username and password per line, separated by a colon
  • Make sure to set the right privileges to the files so Apache can use them
    • chmod 0644 .htaccess
    • chmod 0644 .htpasswd

.htaccess File

AuthType Basic
AuthName "restricted area"
AuthUserFile /home6/path/to/the/directory/you/are/protecting/.htpasswd
require valid-user

.htpasswd File

username:encryptedPassword

Resources