Follow these steps to password-protect a file.

1. Create a file named .htpasswd and place it above your root so visitors can’t access it.
EXAMPLE: /home/username/.htpasswd
2. Put the username and encrypted password inside the .htpasswd file. EXAMPLE:

To create the encrypted password, use an online utility, such as

3.  Place the following code in your .htaccess file, in the same folder where you want to protect the file. (Be sure to replace     usernamewith your actual cPanel username. Replacetestwith the path to your file. Replacefile.htmlwith your file’s actual name.)

EXAMPLE: /home/username/public_html/test/.htaccess
<FilesMatch “file.html”>
AuthName “Member Only”
AuthType Basic
AuthUserFile /home/cpanelusername/.htpasswd
require valid-user


Leave a Reply

Your email address will not be published. Required fields are marked *