Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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/
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

try this .htaccess content

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

.htpasswd shud look similar to this

share|improve this answer

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/ username

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

htpasswd /var/www/vhosts/ username

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.