I won’t go into detail what exactly is needed in your
.htaccess, since it often depends on your hosting provider which instructions are allowed. If you are new to all this stuff and want to password protect your website or parts of it, have a look in the part Password Protection of the Comprehensive guide to .htaccess written by Feyd.
The login data, in detail just the password is stored encrypted in the .htpasswd-file but you have to encrypt it before writing it in this file. On a Mac you can benefit from the underlying Unix-technology for quickly generating your login accounts using the commandline utility
Just open Terminal application and type in the following code and replace username and password with your desired data:
htpasswd -nb username password
and press enter. Terminal should output a new line containing your login data with an encrypted password. Just paste it in your
.htpasswd-file and you’re done.
It’s that easy.