What is a .htaccess file?
.htaccess files are a commonly used method to limit access to folders and files on websites to certain users, by checking the details provided against a .htpasswd file.
What is a .htpasswd file?
A .htpasswd file contains usernames and passwords protected using a form of encryption.
How can I use them together?
You can password protect your site using a simple editor (ie Notepad). First create the .htaccess file as shown below:
AuthName "My Protected Area"
AuthType Basic
AuthUserFile /home/vhost/yourdomain.com/other/.htpasswd
require valid-user
The AuthName section is simply a friendly name displayed for users accessing your protected folder, and can be changed to what you desire.
The AuthUserFile is the absolute path to your .htpasswd file (which we will cover shortly). It is recommended that you put this in the "other" folder in your FTP area. This is more secure, as the "other" folder is only accessible via FTP.
To create your .htpasswd file, enter a username and password into our .htaccess password generator, then copy the results into a text editor and save the file.
Example of contents of a .htpasswd file
user1:eDhyzKzJWK.Sw
user2:e1mzuetlsA6SQ
Once the files are uploaded to the correct locations your folders will only be accessible by anyone with a valid username and password.