Apache htaccess and htpasswd

In order to protect a site or a directory using Apache htaccess and htpasswd files follow the steps-

1. Creating .htaccess file and putting the following code-

AuthUserFile /your/abosolute/path/to/this/file/.htpasswd
AuthGroupFile /dev/null
AuthName "Protected files"
AuthType Basic
<Limit GET>
require valid-user
</Limit>

2. Create a .htpasswd in the same directory as .htaccess and put your generated code. Now the big question how to get a ‘generated code’. Apache used bas_64 encoding. A good web based generator is-

http://www.htaccesstools.com/htpasswd-generator/

Save the file.

And here you go! Your site is protected!

Share

Leave a Reply

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