0

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:

/var/www/vhosts/[MYURL]/httpdocs/clients/[CLIENT]/trade/.htpasswd

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?

Matt27
  • 1
  • 1
  • 2
  • 1
    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
  • 1
    I think you want to look up the "htpasswd" command, which if you run it as "htpasswd -n ", it will output the line that you need to put in your .htpasswd file. – Eirik Toft Jun 16 '14 at 20:43
  • Problem solved! Needed to change to a generated encrypted password! – Matt27 Jun 16 '14 at 20:45
  • I managed to solve this. The issue was because in my .htpasswd file I hadn't used an encrypted password and had just tried to use plain text. Original not working .htpasswd `code`admin:admin Working .htpasswd `code`admin:$apr1$.qqvOm22$uQmilaI66H88o5qiq/UbD1 (if you're looking for a password generator, I used: http://www.htaccesstools.com/htpasswd-generator/) Thanks! – Matt27 Jun 16 '14 at 20:48
  • You can also use the htpasswd binary as I specified above which should be in the apache/bin directory – Eirik Toft Jun 16 '14 at 21:16

0 Answers0