Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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've been trying to use .htaccess to password protect a folder for a website. Unfortunately I can't seem to get it to work. I'm not getting an error, but the password being set in the .htpasswd file is not working.

Any help would be much appreciated.

I can only assume my issue is I'm getting the path wrong for my .htpasswd file.

I used php to find the path and got this:


so I used the following code in my .htaccess:

AuthType Basic
AuthName "Secure Area"
AuthUserFile /var/www/vhosts/[MYURL]/httpdocs/clients/[CLIENT]/trade/.htpasswd
Require valid-user

Anyone got any ideas as to why my passwords aren't being accepted?

share|improve this question
Are you using the right format in the .htpasswd file? Can you post an example of what you made with bogus credentials? – mtak Jun 16 '14 at 20:39
So is the server requesting a password but the configured password isn't accepted? – Shane Madden Jun 16 '14 at 20:39
Yeah, pops up looking for password, but the password I input isn't accepted. My .htpasswd text looks similar to this: admin:admin – Matt27 Jun 16 '14 at 20:40
Could it be because I haven't encrypted it? I originally used an online generator to get a password, but that didn't seem to work on my localhost, so I changed it to the exact text. Now that it's on a server I guess I could try a generated password again. Will post update. – Matt27 Jun 16 '14 at 20:42
I think you want to look up the "htpasswd" command, which if you run it as "htpasswd -n <username>", it will output the line that you need to put in your .htpasswd file. – Eirik Toft Jun 16 '14 at 20:43

Your Answer


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

Browse other questions tagged or ask your own question.