Password protect web folders on linux- htaccess

Published by

Posted on August 08, 2018

create a file called htaccess and type in the following

AuthUserFile /usr/local/apache/htdocs/admin/.htpasswd
AuthName “Authorization Required”
AuthType Basic
require valid-user

the htpasswd file can be create using the following method

from ssh _ shell access needed

htpasswd -c /home/user/.htpasswd admin

the above will create a password file with the user admin .. the password will be encryted

in summary , the htaccess file goes nto the folder you wish to protect . the htpasswd file will go into a none public folder ..

——-

# mod_rewrite
<Directory “/homedir/htdocs”>
Options +FollowSymLinks
AllowOverride All
</Directory>

 

https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html


About the Author