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

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/website/path/.htpasswd

Save and you are done.

Advertisements

One thought on “Linux: How to password protect your website directory by .htaccess

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s