What is a htpasswd?
A .htpasswd file is typically used to protect a file, folder or even an entire website. It stores usernames and password for basic authentication.
You can easily protect the site from outside viewers with a few simple steps.
Create a .htpasswd file in the root directory of your website.
You will now need to generate the username and password for your site. You can easily do that with the Htpasswd Generator.
Generate the .htpasswd code and copy the output.
Open the .htpasswd file and paste the code generated by the Htpasswd Generator.
Don’t forget to save the file!
We’ll now need to add the following code to the .htaccess file.
AuthUserFile /path/to/.htpasswd
AuthType Basic
AuthName "My restricted Area"
Require valid-user
Don’t forget to save the file!
Important! Note that the “AuthUserFile /home/wpxtest/public_html/.htpasswd” line is different.
You will need to change the path to the file. Let’s see how can we do that.
/home/wpxtest/public_html/.htpasswd
We need to start with the home directory where the hosting plan is located: /home
Followed by the account user: /wpxtest
We’ll then need the path to the site:/public_html
We then add the file that we’d like to access: /.htpasswd
Important! If your website is not located on the main domain the path to the site would be:
/home/wpxtest/domains/mywebsite.com/public_html/.htpasswd
The user can be located in the Service Details menu:
After we make sure that everything is correct, navigate to the website.