How To Enable .htaccess Password Protection

How to Enable .htaccess password protection

Written by - Ali adrees

December 24, 2018

.htaccess Password Protection

The .htaccess authentication or .htaccess password protection is the method in which we can protect our folder or directory. We just need to create a text file with the name .htpasswd and write few lines of code in it. Then we upload both .htaccess and .htpasswd files in the specified directory for which the 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 damages you can get help by 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 into 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 htpasswd generator to create new password. Every line in the .htpasswd file contains a username and password combination, so do not hesitate to add different and required combinations.

    You May Also Like…

    0 Comments

    Submit a Comment

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