Posted By

jonhenshaw on 09/26/07


password unix linux htaccess apache protect htpasswd protected

Versions (?)

Who likes this?

3 people have marked this snippet as a favorite


Password Protect Folder / Directory with htaccess and htpasswd on Apache and Linux / Unix

 / Published in: Bash


Good info here too:

  1. Step 1 - Create .htaccess file in folder you want to protect, copy the code and paste the code below, and then set server path to the file
  3. AuthUserFile /path/to/.htpasswd
  4. AuthName "Restricted Area"
  5. AuthType Basic
  6. Require valid-user
  9. Step 2 - Open Terminal, go to the directory you want to protect, and enter the following (changing the username to whatever you want). Enter the password upon prompting.
  11. htpasswd -c .htpasswd username

Report this snippet  


RSS Icon Subscribe to comments
Posted By: kmartiin on September 10, 2009

i asked myself how to protect a specific file here is how:

AuthUserFile /path/to/.htpasswd AuthName "Restricted Area" AuthType Basic

require valid-user   #or use a specific user

Posted By: kmartiin on September 10, 2009

strange ... i dont really know how to format code the right way using markdown. maybe you could just add this to your snippet

You need to login to post a comment.