How Do I Create A Password Protected Directory?

Plesk

  1. After loggging on to your Plesk control panel you will want to click on the "Home" link on the left-hand menu.  When the page loads click on the "Protected Directories" icon under the "Hosting" category.
  2. Under the "Tools" category click on the "Add New Directory" icon.
    1. Fill in the "Directory name" with the directory that you want protected.  If you have a directory in /httpdocs/mydir, you would enter "/mydir" into the Directory name field
    2. Check both Non-SSL and SSL for the location, and only click cgi-bin if the directory is in your /cgi-bin directory instead of your /httpdocs directory
    3. The header text can be anything you want.  The user will see this on the password prompt window.
    4. Then click OK
  3. The configuration page for the new protected directory will be displayed.  Click on the "Add New User" icon.
    1. Enter the Username and Password into the fields and press OK
  4. After adding a user you can browse to that protected directory and it should prompt your for the Username and Password.


Shell (Only if you have this enabled for your website)

  1. SSH in, and login using the adminstrative FTP username and password
  2. Navigate to the directory you want to password protect.
  3. Create the .htaccess file, it should contain the following lines:
    # Access file
    order allow,deny
    allow from all
    require valid-user
    Authname DirectoryName
    AuthPAM_Enabled off
    Authtype Basic
    AuthUserFile /var/www/vhosts/YourDomain/httpdocs/Directory/.htpasswd
    Make Sure To Replace DirectoryName, YourDomain and Directory as appropriate
  4. Now you must create the .htpasswd file using the htpasswd tool.
    1. Type the following command to create the file and add a user:
      htpasswd -c .htpasswd username
    2. You will be prompted for the users' password twice.
  5. If you need to add additional users to the file, use the command above without the -c.
Last Updated on 23 Apr, 2014 - 0 Views