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
<VirtualHost *:80>
#    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
<Directory "/var/www/html/passdir">
AllowOverRide AuthConfig
</Directory>
</VirtualHost>

# service httpd restart
Share on Google Plus

About Penguin Technology

I am a passionate cloud and DevOps professional specializing in Linux and open-source solutions. Through this blog, I share my knowledge and experience with the community, offering tips and insights on cloud technologies and DevOps practices.
    Blogger Comment

1 comments:

  1. I gathered as much knowledge regarding to the Linux, web sever and database server from your site.Keep on updating with more interesting topic.
    Moreover to recover the lost file from Linux Click on:
    android data recovery review
    launch android data recovery
    backup and restore android apps and data
    android backup app data
    recover lost files
    diskdigger pro file recovery

    ReplyDelete