Password Protect a Directory

1. Create a .htaccess file

AuthName "Secure Area"
AuthType Basic
AuthUserFile /path/to/your/directory/.htpasswd
require valid-user

2. Create a .htpasswd file under the account using this command

htpasswd -c .htpasswd your-user-name
and give the password

3.  If you have more than one user, then
htpasswd .htpasswd another-user-name

4. Make sure the permission of file .htpasswd is 644

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