Password protecting your site in the DreamHost panel

 

Overview

This article describes how to use the panel to password protect your website or a subdirectory on your website.

No access to your .htaccess and .htpasswd files

The instructions in this article create an .htaccess and .htpasswd file which will be owned by the server. This means you will not be able to manually edit either of these files if you need to. Additionally, these instructions will overwrite any existing .htaccess file. Make sure to backup your existing .htaccess file before beginning these steps.

If you will need access to your .htaccess and .htpasswd file at any time in the future, you should follow the directions in the following article instead to manually create these files. 

Password-protecting a directory

  1. Navigate to the Htaccess/WebDAV page.
  2. Click the domain you wish to password protect. A list of your 'fully-hosted' domains appear.
  3. Click the Set Up a New Directory button.
  4. Edit the fields as described in the following table.
    Field Name
    Action and Description
    Directory name
    Enter the directory you'd like to protect (leave it blank to protect the entire domain.)
    Password-protect this dir?
    Check this box.
    Enable WebDAV on this dir?
    You can leave this unchecked if you don’t need to use WebDAV on this domain.
    Directory "name"
    Enter the name to reference in the pop-up window that asks for your password.
    User accounts for this area
    Enter a username and password that is allowed access to the password-protected domain/directory. Each line consists of a single username password in the format 'username password'.
    Forbid linking to files in this dir?
    Check this box if you'd like certain file types to be forbidden.
    Forbidden file extensions
    Add the forbidden extensions here.
    Domains that may still link
    Add domains that will not be forbidden from accessing this directory's content.
  5. Click the Configure This Directory button.

Within about 10 minutes, this directory on your site will be password-protected.

Code added to your files

The steps above create a new .htaccess and .htpasswd file within your website's directory. The .htaccess file consists of the following code:

### Generated by Dreamhost. DO NOT modify!!! ###
AuthType Basic
AuthUserFile /home/username/example.com/public/.htpasswd
AuthName "Members Area"
require valid-user
################################################

The .htpasswd file only shows the encrypted password for a username:

username1:$1$MVq7Nkc/$GTaN0dRkCsiXJpFNxYs8V.

Testing the directory

Visit the password-protected directory in your browser. A pop-up authentication box appears that asks you to enter your credentials.

Only the users you added in the User accounts for this area field are able to access the site.

See also

DreamHost links

Third party links

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?