Password Protect your website using htaccess file
Posted on Nov 08, 2007 under Security, Webserver |There are many ways to password protect your website.The easiest way is to use .htaccess file to password protect your website. This way, username and password will be requested to visit your website.
Create an .htaccess file and include these lines:
AuthName “My Website, Provide Username and Password”
AuthType Basic
AuthUserFile /full/path/to/.htpass
Require valid-user
create an password file :
In your shell:
htpasswd -c .htpass username
The path to the file must be a full path, for example : /home/gravin/public_html/.htpass .If you don’t have a shell to create the password file then you can use this link here to create one. Password Generator .Then create a file named .htpass and upload it in same location as .htaccess file. The username and encrypted password will look something like this in your .htpass file:
gravin:Z3uvWlkzas0CkĀ
Thats it, you will be prompted to enter username and password to proceed to your website. ![]()