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:

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
  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

You need to login to post a comment.