First you need to create a
.htpasswd file somewhere in the system. Run the following command at the command line:
htpasswd -c /home/hidden/directory/here/.htpasswd the_username
Then you can use it for authentication. In your .htaccess file you need something like the following code, but make sure the AuthUserFile is the file path to the .htpasswd you just created. You should keep the .htpasswd in a directory not accesible via the web. So don't put it in your /public_html/ or /www/ directory.
AuthType Basic AuthName "Password Protected Dir Title" AuthUserFile /home/hidden/directory/here/.htpasswd Require valid-user
Remember that for most rules you must have the
RewriteEngine on rule in your .htaccess file!!!
Please remember to double check and verify any rules that you use. If you do not understand a rule please consult someone who does. Or if you are new, please take time to learn the basics of .htaccess. We accept no responsibility for your use of these rules - use them at your own risk. Please get in touch if you want us to add a rule!