Create Password Protect Directory Using .htaccess

If you are looking for a solution to protect your web directory and files from unauthorized user access or you want to make password protected directory so that only selected people can view files then this tutorial is for you, By using simple .htaccess trick you can easily create password prorect directory in less effort, The only thing is required .htaccess supported apache web server.



password-protected-directory-using-htaccess
The system requires two files.
1- .htaccess
2- .htpasswd

.htaccess Code

AuthType Basic
AuthName "restricted area"
AuthUserFile /home/rohit/www/html/protect-dir/.htpasswd
require valid-user

.htpasswd Code

rohit:rohitpass
manish:manish123
ankur:ankur321

Above .htpasswd file contains the usernames and passwords of allowed users. One per line.


If you like this post please don’t forget to subscribe my public notebook for more useful stuff