Make a password protected Website with .htaccess and .htpasswd file
Now you can protect your website by password. So that you can limit the website access from anonymous web users.
This increases your web security. This is done by .htaccess and .htpasswd file on your web server. This is treated as web Locker with .htpasswd file contains the key of locker.
.htaccess: .htaccess file contains the path of .htpasswd file, authentication type, authenticated user name.
Create a new .htaccess file and place the following code in it:
require user admin
AuthUserFile contains the full path of server where .htpasswd file exists.
require user contains the name of the authenticated user. Who is able to access the website.
AuthType Basic is used because we use basic HTTP authentication.
.htpasswd: .htpasswd file contains the username and password which is placed in encrypted form. You can encrypt the username and password here( http://www.htaccesstools.com/htpasswd-generator/ ).
Tip: Don’t Place your .htpasswd file in your root directory. Please put this file in your safe folder like usr/local/you/safedir/.htpasswd
the .htpasswd file would look like this:
If you have any questions about this post please comment or mail us at email@example.com