Posted By

jonhenshaw on 09/26/07


Tagged

password unix linux htaccess apache protect htpasswd protected


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

basicmagic
francisre
vkolev


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


 / Published in: Bash
 

URL: http://ag.arizona.edu/ecat/web/password-protect.html

Good info here too: http://www.ilisys.com.au/support/linux-password-protect/

  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
  2.  
  3. AuthUserFile /path/to/.htpasswd
  4. AuthName "Restricted Area"
  5. AuthType Basic
  6. Require valid-user
  7.  
  8.  
  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.
  10.  
  11. htpasswd -c .htpasswd username

Report this snippet  

Comments

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.