Enable Password Protection on Plesk Subdomains

This tutorial will show you how to enable password protection on subdomains within Plesk (tested on version 9.x). This is especially useful if you want one (or more) login for several different protected subdomains. These steps are necessary as Plesk doesn’t have a GUI feature to enable this.

Follow these steps:

  1. Create a new subdomain i.e, subdomain.yourdomain.com
  2. Create an empty folder in your main site’s root directory (not the subdomain), name it
  3. something relevant i.e, _subaccess
  4. In Plesk, under Protected Directories select Add Protected Directory
  5. Insert the same as your folder name from Step 2 i.e, _subaccess
  6. Click the _subaccess and create a user/s who will need access
  7. Within the subdomain public html root, create an .htaccess file and add the following:
 AuthType Basic
AuthName " "
AuthUserFile /var/www/vhosts/yourdomain.com/pd/d..httpdocs@_subaccess
require valid-user

That’s it. You should now have password protection for any subdomain under yourdomain.com that you choose to to drop an .htaccess file into (as above).

Note: The location above, /pd/d..httpdocs, looks a bit funky, but that’s what it needs to read. httpdocs may be called something different on your server, like public_html etc.