0

i've been having trouble in the last hour with htaccess file.

so what i want: I have a folder which is located at http://myip.com/FOLDER and I want a simple authentification page via htaccess

So i did the following:

sudo htpasswd -c /home/daniel/.htpasswd daniel

Please do notice I'm a pure beginner and ive been following a guide. anyways I think with that command i store my htpasswd file in my home folder.

entered pw blablabla etc, worked so far ^^.

I also created a ssl vhost:

my content: File: /etc/apache2/sites-available/default-ssl

<Location /myfolder>
AuthName "Private"
AuthType Basic
AuthBasicProvider file
AuthUserFile /home/daniel/.htpasswd
Require valid-user
</Location>

ServerName XYZX:443
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key

default: ServerName my adress Redirect permanent / my adress

i get ssl and stuff but never the authentification page

apache2 restarted but I just never get the authentification page :(

would appreciate help

thanks

tamani
  • 39
  • 1
  • 5

3 Answers3

1

You have setup authentication in the default-ssl config file, so it will only work for the https site.

Regarding your comments, it seems that authentication for https://myip.com/myfolder works as expected.

Now, from my understanding, it seems you want the same behaviour for http://myip.com/myfolder.

If it is the case, i suggest to put the same <Location> config in file /etc/apache2/sites-available/default


EDIT

Ok, so you should try to setup your <location> like this in /etc/apache2/sites-enabled/000-default :

<Location /myfolder>
    Order allow,deny
    Allow from all
    AuthName "Private"
    AuthType Basic
    AuthBasicProvider file
    AuthUserFile /home/daniel/.htpasswd
    Require valid-user
</Location>
krisFR
  • 13,280
  • 4
  • 36
  • 42
1

Try to put the config in a file called .htaccess in the same folder you want to protect:

AuthName "Private"
AuthType Basic
AuthBasicProvider file
AuthUserFile /home/daniel/.htpasswd
Require valid-user
ojovirtual
  • 291
  • 2
  • 7
0

You didn't show any enclosing <Virtualhost> directive in /etc/apache2/sites-available/default-ssl, but assuming there is one, that's an HTTPS-only host. So does the authentication work at https://myip.com/myfolder ?

Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47