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


/ Published in: Bash
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.