How do i password protect subdomain directories in plesk

You can protect the subdomain directories in plesk using .htaccess and .htpasswd files. Follow the stpes below :

>> SSH to the server with root user
>> Go to the folder which you want to be password protected :

[root@server ~]# cd /www/vhosts/

NOTE : “” will be replaced with your domain main domain and “Directory” replaced with the folder that you want to protect.

>> Now create .htaccess file :

[root@server ~]# vi .htaccess

Enter the below code in .htaccess file :

AuthType Basic
AuthName “Authentication”
AuthUserFile /www/vhosts/
Require valid-user

Save and exit from the file .htaccess.
>> Then create .htpasswd file under the same directory or the directory which you’ve specified in your .htaccess file. Here I’ve created .htpasswd file at /www/vhosts/

[root@server ~]# vi ..htpasswd

Edit this file and enter the username and password combination. You can enter one per line. Or you may create the htpassword file using the link and enter the code that is generated using this link to the file .htpasswd file.

Save and exit from the file.

>> OR you may Run the command as below :

[root@server ~]# htpasswd -c .htpasswd username

NOTE : username will be replaced with your username.

It will prompt you to set a password and create a file in that folder called .htpasswd with the username and encrpyted password for it.

Thats it!!! Now you have your subdomain with protected username and password.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: