Take the 2-minute tour ×

I'm trying to set up a protected directory on my Linux server that is running Apache.

I'm following the instructions that my host has given me. Setting it up using Plesk control panel, doesn't work, so I'm doing it via SSH.

I'm generating a .htpasswd file in directory


Then I'm creating a .htaccess file in directory that I want to protect and pointing it to .htpasswd file. Here are contents of my .htaccess file

AuthUserFile /var/www/vhosts/mysite.com/.htpasswd
AuthGroupFile /dev/null
AuthName "Authentication Pop Up"
AuthType Basic
require user username

Now when I browse to that directory I get a prompt to log in. However, I can't log in with username/password that I have created. My guess is that .htaccess file is not finding the .htacess file. But I'm not sure, there are no errors.

share|improve this question
add comment

2 Answers

try this .htaccess content

AuthName "Admin Area or whatever you want"
AuthType Basic
AuthUserFile "/var/www/vhosts/mysite.com/.htpasswd"
require valid-user

.htpasswd shud look similar to this

share|improve this answer
add comment

First all, I suggest you to remove the LIMIT POST GET section of your htaccess file because this introduces a security issue with PHP files.

As dev.e.loper, I think that your .htpasswd file is wrong, you can create one using this command :

htpasswd -c /var/www/vhosts/mysite.com/.htpasswd username

To add or modifies your password (can be useful later) :

htpasswd /var/www/vhosts/mysite.com/.htpasswd username

Make also sure that the file have the good rights and that it is accessible for the Apache user.

share|improve this answer
add comment

Your Answer


