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.
The system requires two files.
AuthType Basic AuthName "restricted area" AuthUserFile /home/rohit/www/html/protect-dir/.htpasswd require valid-user
rohit:rohitpass manish:manish123 ankur:ankur321
Above .htpasswd file contains the usernames and passwords of allowed users. One per line.