Introduction
There are many uses of the .htaccess by far the most popular and probably most useful is being able to reliably password protect directories on website. You can do it in a couple of steps.
Step 1:
Create .htpasswd file with your desired username and password in any text editor and save without the name. It is a good idea to encrypt the password for extra protection, As you visit the link, simply enter the username and password and it will generate the code for you, which you can copy and paste.
Step 2:
Create .htaccess file with the below code. It can be created using any text editor. Remember check the location of the .htpasswd file, or it will not work. You can change 'Login Details' to whatever you want display on popup alert:
AuthUserFile /home/user/domain/secretfolder/.htpasswd
AuthType Basic
AuthName “Login Details”
Require valid-user
Step 3:
Upload both files in the same folder which you want protected. Now whenever anyone accesses that directory or any files in it, they will be asked for login. Your Web Directory is password protected now.
AuthType Basic
AuthName “Login Details”
Require valid-user
how to use .htaccess Part 3: Password Protection
Reviewed by Snehal Vasava
on
May 21, 2018
Rating:
Reviewed by Snehal Vasava
on
May 21, 2018
Rating:

No comments: