0

I have a directory, lets call it sub, which is a sub-directory of the root directory.

In this subdirectory I have a .htaccess file which looks like this:

AuthType Basic
AuthName "Initial Zugriff verweigert - Bitte Authentifizieren Sie sich."
AuthUserFile sub/.htpasswd
Require valid-user

DirectoryIndex info.php

sub/ also contains the files: info.php and the .htpasswd file.

Whereas info.php is a simple php file like this:

<?php
phpinfo();
?>

When I put info.php into the root directory or delete the .htaccess file it works just fine and shows me the php7 informations, but when put behind the .htaccess file it gives me a

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

I'm not able to access the apache error logs since I'm on a shared hosting server from 1und1.

I'm thinking the .htaccess is the problem and I have to allow php to work in the protected directory. How can I accomplish that?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Lyux
  • 453
  • 1
  • 10
  • 22
  • i think your path to htpasswd file should be AuthUserFile .htpasswd instead of AuthUserFile /sub/.htpasswd in htaccess file – Shahrukh Sep 22 '17 at 14:15
  • you can remove or rename the .htaccess. Especially if there is no .htpasswd. – Calimero Sep 22 '17 at 14:15
  • 1
    Check your Apache error.log for the reason of 500 error. It could be due to permissions on `.htpasswd` file. It should be kept outside `DocumentRoot` for security reasons. – anubhava Sep 22 '17 at 14:19
  • @anubhava as i said i don't have access to the apache error logs. – Lyux Sep 22 '17 at 14:25
  • @Calimero well there is a .htpasswd in the same directory as the .htaccess file. – Lyux Sep 22 '17 at 14:26
  • @anubhava and neither of them are in the documentroot, they are in the sub directory. – Lyux Sep 22 '17 at 14:27
  • @anubhava so you have no idea aswell? – Lyux Sep 22 '17 at 14:28
  • 1
    `AuthUserFile` needs full filesystem path not website path. `AuthUserFile /sub/.htpasswd` means `/sub/` must be a valid filesystem path and there should be a directory `sub` directly filesystem root. Does `ls -al /sub/` show you password file? – anubhava Sep 22 '17 at 14:29
  • https://stackoverflow.com/questions/5438060/showing-all-errors-and-warnings – aynber Sep 22 '17 at 14:31
  • @aynber i already enabled this but it doesn't throw any errors. – Lyux Sep 22 '17 at 14:34
  • @anubhava will check this later, thanks for the help. – Lyux Sep 22 '17 at 14:34
  • @anubhava the Comment `ls -al sub` gave me the password file. – Lyux Sep 22 '17 at 16:10
  • @anubhava Well you were right on that one, i changed the line in the .htaccess file to `AuthUserFile sub/.htpasswd` so that `ls -al sub/` gave me my .htpasswd . – Lyux Sep 22 '17 at 16:37
  • This doesn't change the outcome tho, i still get `Failed to load resource: the server responded with a status of 500 (Internal Server Error)` – Lyux Sep 22 '17 at 16:37
  • @anubhava when using the full system path the authentication on the web doesn't work anymore... like in he doesnt seem to find the `.htpasswd` file anymore when using the full filesystempath. What does it even matter, the authentication does work when using it like this: `AuthUserFile sub/.htpasswd`. what else could cause a 500er Error? – Lyux Sep 22 '17 at 19:11

0 Answers0