Password Protect Site using htaccess

To password protect a web site or a sub folder using .htaccess, create a .htaccess file in the folder.

Add following content

In this case, i used /etc/apache2/site-logins as AuthUserFile, this will store all user and password. You can change this file path to whatever you need. Make sure it is not accessable from public, so keep it outside of document root of your web site.

Now create a user with command

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *