Password Protect Directory
Password Protect Directory Tutorial
This tutorial is about protecting directory on apache web server using .htaccess.
This .htaccess protect directory is built-in method in apache.
Just upload the .htaccess in such directory, and then your directory will be restricted from
In order to restrict access to chosen directory, we need to create
an .htaccess file. Following is common .htaccess for protecting directory:
AuthName "Please Login"
It is authentication type being used. In this case, it will be set to Basic. Basic is most common used in this type of authentication.
The atuhentication name or title, it will be displayed in the pop up box.
The location of file which contains username and password list. You should type exact location from root directory, e.g: /home/users/abc/www/.htpasswd
The requirement which must be satisfied in order to grant admission.
After .htaccess created, we need to create .htpasswd. This file will be saved in AuthUserFile location.
.htpasswd content will be like this:
You can generate manually .htpasswd using above .htpasswd generator.
If you want to generate automatically you can use this unix command:
htpasswd -c .htpasswd yourusername