Skip to content


htaccess and htpasswd

Have been using htaccess and htpasswd to protect my directories for a every long time, and after copy pasting the same stuff over and over many times, I have decided to add a post here so I can copy paste easier next time.

To password protect a directory:

vi .htaccess:

AuthUserFile /PATH TO PASSWORD FILE
AuthName "PHASER Password"
AuthType Basic

require valid-user

[Close vi]

htpasswd -cm [PATH TO PASSWORD FILE] [USERNAME]

[Enter password]

chmod 640 .htpasswd

chmod 644 .htaccess

Done!

Posted in Technology. Tagged with , .