How to create/protect password in web directory using httaccess


Make file in Document root on which you want to protect password
cd /var/www/html/passdir

Create file
#vim .htaccess        (add in file)
authname "Type username and password"
authtype basic
authuserfile /etc/httpd/passwordinfo
require   valid-user

Create password for user authentication

#htpasswd -c -m /etc/httpd/passwordinfo shahzad

Apache Config file entry

# vim /etc/httpd/conf/httpd.conf

#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /var/www/html
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common

AllowOverRide AuthConfig



# service httpd restart