Pages

Friday, April 12, 2013

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/yourdomai.com/subdomains/directory/httpdocs/
NOTE : “Yourdomain.com” 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/yourdomai.com/subdomains/directory/httpdocs/.htpasswd
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/yourdomai.com/subdomains/directory/httpdocs/.htpasswd
[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 http://www.htaccesstools.com/htpasswd-generator/ 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.

No comments:

Post a Comment