Apache offers you to protect a folder and its subdirectories with .htaccess files. Learn how to protect your data in only two quick steps!
1. Create an .htpasswd file
Your .htpasswd file will contain the usernames and crypted password of the users who will be allowed in the directory you want to protect; htpasswd files typically look like this:
…where the part before the semicolon represents the username, and the right part is the encrypted password.
How to generate an htpasswd file ? Just follow these two easy steps:
- use this online htpassword generator, type the users you want to add and copy the generated text
- paste the text in a file named .htpasswd
2. Configure the .htaccess
Create a file named .htaccess at the root of the folder you want to protect, if it does not already exists. Paste this few lines in the file, then save it:
AuthName "Type a custom text here" AuthType Basic AuthUserFile /full/path/to/the/.htpasswd AuthGroupFile /dev/null require valid-user
You will have to edit the location of your .htpasswd file (/full/path/to/the/.htpasswd) for this to work properly.