Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

/var/www/vhosts/mysite.com

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
<LIMIT POST GET>
require user username
</LIMIT> 

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

2 Answers 2

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

username:$1$Iwj.wNmb$bTva2aQYaOXg.YVg.EIpA/
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/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

Your Answer

 
discard

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.