Home / Security / Password Protecting Your Directories

Password Protecting Your Directories

password dialog
Question: How do I password protect a directory on my website?

Answer: Many web hosting control panels offer a “password protect” feature for your directories. If not, there is a moderately easy way to do it with an Apache .htaccess file.

First, create an .htaccess file that looks like this:

AuthUserFile /home/yourname/.htpasswd
AuthName “Password Protected”
AuthType Basic
require user yourname

Replace “yourname” with your desired username. Next, you will need to create the .htpasswd file in the location you specified. This requires you to have an encrypted password entry:


Use the following form to create one: Htpasswd Generator.

Check Also


Importance of web hosting to business

The world of business is very ruthless and unfair in some cases. It is a …