The article reveals the steps to enable .htaccess password protection.
1. Firstly, create an .htpasswd file with your own username and password in any text editor and save it without the .txt extension. Encrypt the password for extra protection.
2. After visiting the link, just enter the username and password. This will generate the code for you that you just need to copy and paste. In this example, the username was ‘abc’ and password too was ‘abc’ and so the result was – abc:9476nIHW7Esgw. But it generates a new one each time.
3. Next, create an .htaccess file with the below code. You can use any text editor save it without the .txt extension. Don’t miss to check the .htpasswd file’s location or else it won’t work.
4. It is possible to change the ‘Login Details’ to anything you want to be displayed on the pop-up alert.
AuthUserFile /home/user/domain/secretfolder/.htpasswd AuthType Basic AuthName “Login Details” Require valid-user
5. Both these files need to be uploaded in the same folder which you want to be secure. Now, if any other user than you tries to access that directory or any files in it, they will be asked for login details. So, your web directory is now secured with the password.