How to password protect a website folder using .htaccess and .htpasswd

How to password protect a website folder using .htaccess and .htpasswd

To add password protection is quite straightforward

  1. Create a .htpasswd file in either the location of the file you want to protect i.e /home/<your username >/public_html/.htpasswd

Go to the link below and generate a password that you will use inside your .htpasswd

Note: use the generated hash and username as it is don't use your real password

check the generator tool here at GET TOOL HERE

Create a .htaccess file if it does not exist and add the following

AuthType Basic
AuthName "Restricted Area"
AuthUserFile /home/<your username >/public_html/.htpasswd
Require valid-user        

And thats all it requires to protect your folders or websites

要查看或添加评论,请登录

Bonface Maina的更多文章

社区洞察

其他会员也浏览了