Linux: How to password protect your website directory by .htaccess


How To Tutorials

Website directory password protection by .htaccess

This tutorial will help you to create directory protection for your website folder.

Lets assume that your website home path is /home/mypath/  and you want to use ‘website’ as username and ‘password’ as directory password:

Step 1: Go to your server by SSH and in command prompt type following command:

$ htpasswd -c /your/mypath/.htpasswd website

put your password that you want to use for directory protection, in this example it is `password`

Step 2: go to your website .htaccess file and paste the following code in the top.

AuthType Basic
AuthName "Authorised access only"
AuthUserFile /home/savvysme/.htpasswd

Save and you are done.

View original post