HostOnNet Blog

Password Protect a Folder with .htaccess

Looking for Linux Server Admin or WordPress Expert? We can help.

To password protect a folder in Apache, create a password file

[root@server12 ~]# htpasswd -c /path/to/.htpasswd admin
New password:
Re-type new password:
Adding password for user admin
[root@server12 ~]#

This is create a password with user user “admin”.

This file should be outside Apache document root.

Now create a .htaccess file with following content in the password protected folder.

AuthUserFile /path/to/.htpasswd
AuthName "Members Only"
AuthType Basic
Require valid-user

To access the folder, you will need to login as admin user created above.

Posted in Apache

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.