Htpasswd generator
With this .htpasswd generator you can easily create a htpasswd file.
You need a .htpasswd file to be able to log in with htaccess.
Htpasswd is a text file with the filename “.htpasswd” with in it a few lines of text. Do you want to add more users to this htpasswd file, add more lines to the file, each line is a separate user that is able to log in.
Is a .htpasswd generator needed?
There are several ways to generate a htpasswd file, the easiest way to do it is with ssh.
With the ssh command: “htpasswd -d /yourpath/.htpasswd yourusername” you can create a htpasswd file or add new users. After executing this command you’ll get a request to fill in the wanted password.
Not everyone has access to the ssh console and not every hosting control panel is that easy to use. In the case this is your case the best option is to use this page to generate the htpasswd file.
Log in with .htaccess
If you place your htpasswd file in a directory, and if you add a htaccess file to this directory you will get a login screen when browsing to this directory. It saves a lot of time if you only need to protect a simple script for unwanted access.
Example .htaccess
With the lines in the codeblock below you can generate a htaccess file to use for logging in. Copy and paste the line in a file with the filename “.htaccess” and make sure you change the path to the htpasswd file correctly.
RewriteEngine On
AuthType Basic
AuthName “Website login”
AuthUserFile /var/www/vhosts/website.com/.htpasswd
AuthGroupFile /dev/null
Require valid-user
Example .htpasswd file
The following lines should be in a file with the filename “.htpasswd”. Not sure if you understood correctly? In the block below there is the content of a htpassword file with 2 users:
garry:$apr1$dmbrstqe$pENY4VsoIx1TLjinI4HGT/
janice:$apr1$h051lttr$SZcQl7EqrjQBk4BWg3NXy.