We Recommend

bash Cookbook: Solutions and Examples for bash Users bash Cookbook: Solutions and Examples for bash Users
bash Cookbook teaches shell scripting the way Unix masters practice the craft. It presents a variety of recipes and tricks for all levels of shell programmers so that anyone can become a proficient user of the most common Unix shell -- the bash shell -- and cygwin or other popular Unix emulation packages.


Posted By

jonhenshaw on 09/26/07


Tagged

password unix linux htaccess apache protect htpasswd protected


Versions (?)


Who likes this?

2 people have marked this snippet as a favorite

basicmagic
francisre


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 

You need to login to post a comment.