Skip to Navigation

Home -> Online Tools -> Password Protect Directories

Password Protect Directories using .htaccess -

Fill out the form below and we will automatically generate the code to go in your .htaccess and .htpasswd files.

Step by Step GuideFirst make a file called .htaccess (just start 'notepad', when you save the file call it .htaccess Nothing before the '.' Change 'Save as Type' from Text Document to All Files then click Save) put the following text in the file:


AuthName \"Password Protected Directory\"
AuthType Basic
AuthUserFile /your/server/path/.htpasswd
require valid-user


Then save the file in the directory you wish to protect. You must call it .htaccess with nothing before the .
Remember to change line 3 (above) to reflect the path to the directory you are going to put the next file .htpasswd file

Then make a file called .htpasswd Below is the text you need to enter into your .htpasswd file, then upload both the files to the directory you want to protect!

This is your username and encrypted password"; echo "


"; echo nl2br($htpasswd_text); echo "


Thats it try going to a page in the directory you placed the .htaccess file. You can add more than one user to a .htpasswd file.
Just make sure to leave one blank line at the end of both files.


"; } else { echo "


"; echo "Passwords do not match"; echo "


"; } } ?>
Username:
Password:
Password again:

Note: We do NOT store your usernames and passwords.