Introduction
The .htaccess authentication or access password protection is the method by which we can protect our folder or directory. We just need to create a text file with the name .htpasswd and write a few lines of code in it. Then we upload both .htaccess and .htpasswd files in the specified directory for which password protection is required.
- AuthType Basic
- AuthName “Password Protected Area”
- AuthUserFile /path/to/.htpasswd
- Require valid-user
You just need to replace the “/path/to/.htpasswd” with the full path to your .htpasswd file. You can find the full path using PHP and make changes by yourself but to avoid serious damage you can get help from our professionals. Then you need to upload the .htpasswd file into the password-protected folder. Please double-check that your .htpasswd file has the username and password in it. The .htpasswd file should contain:
- test:dGRkPurkuWmW2
The above-mentioned code will grant the user “test” to approach the password-covered portion with the password “test”. The text “dGRkPurkuWmW2” is an encrypted version of the password. You will need to use the htpasswd generator to create a new password. Every line in the .htpasswd file contains a username and password combination, so do not hesitate to add different and required combinations.