If you want to provide password protection for your webpages, follow the steps below:
Create a .htaccess file under the directory (which you want to protect):
To protect the entire directory
AuthType Basic
AuthUserFile /docroot/<username>/.htpasswd
AuthGroupFile /dev/null
require valid-user
To protect individual files like test.html, testing.html:
AuthType Basic
AuthUserFile /docroot/<username>/.htpasswd
AuthGroupFile /dev/null
<Files test.html>
require valid-user
</Files>
<Files testing.html>
require valid-user
</Files>
docroot/username/.htpasswd is the file where you want to put the username(s) and encrypted password(s).
You can create this “htpasswd” file using the command:
This command will give you an output like username:P/X0BsSU.aEKM Put this line to your .htpasswd file.





