I recently created a webpage that i want to protect with a password. I tried to use .htaccess to protect my index.html site but when i try to access the page, it returns error 401. Here is the code that i use.
AuthUserFile home/mywebsite/public_html/mywebsite.com/webspecial/.htpasswd AuthType Basic AuthName "Special Page" <Files "index.html"> Require valid-user </Files>
I hope someone can help me on this.
Thank you very much.
You can use the Password protect directory feature from cPanel, instead of using .htaccess.
I have never seen it being used to login for a file, as in your case, but for directories.
Hope it helps!
@jpablo I also tried that one at first but the problem is after i put password on it and try accessing the page on the website, instead of a prompt of a password to access the page, it shows 401 error or web page does not exists.
@CMS I have tried to use the password protect feature on cpanel and worked perfect for me.
What I would do, in your case is delete the .htaccess file and the passwd file, and then use the cpanel password protect. Maybe the passwd file you created doesn't work well with cpanel.
Let me know if that helps!