Online Network Tools

Your IP Address:

Password Protect Directory

Generate .htaccess
Auth Name
This name will be displayed in the login box when a user acces your protected area for the first time.

.htpasswd File Location
Enter the full path to your .htpasswd file.


Generate .htpasswd


Password Protect Directory Tutorial

This tutorial is about protecting directory on apache web server using .htaccess. This .htaccess protect directory is built-in method in apache. Just upload the .htaccess in such directory, and then your directory will be restricted from unathorized access.

Create .htaccess
In order to restrict access to chosen directory, we need to create an .htaccess file. Following is common .htaccess for protecting directory:
    AuthType Basic
    AuthName "Please Login"
    AuthUserFile /var/local/user/.htpasswd
    Require valid-user

AuthType It is authentication type being used. In this case, it will be set to Basic. Basic is most common used in this type of authentication.

AuthName The atuhentication name or title, it will be displayed in the pop up box.

AuthUserFile The location of file which contains username and password list. You should type exact location from root directory, e.g: /home/users/abc/www/.htpasswd

Require The requirement which must be satisfied in order to grant admission.

Create .htpasswd
After .htaccess created, we need to create .htpasswd. This file will be saved in AuthUserFile location. .htpasswd content will be like this:
You can generate manually .htpasswd using above .htpasswd generator.

If you want to generate automatically you can use this unix command:
    htpasswd -c .htpasswd yourusername