Frage

Ich versuche, einen Ordner mit '.htaccess' und '.htpasswd' zu schützen.

ich benutzte http://www.tools.dynamicdrive.com/password/ So generieren die Dateien.

Kopierte sie in die entsprechenden Ordner.

Als ich versuchte, auf den geschützten Ordner zuzugreifen, Ich habe eine Login -Eingabeaufforderung.

Geben Sie falsche Anmeldedetails ein und erhalten Sie zur Fehlerseite.

Alles gut.

Jetzt, ohne Änderungen, überprüfe ich die Seite, um mich erneut anzumelden, um auf den geschützten Ordner zuzugreifen, und sie wirft einfach einen Fehler aus. Es gibt kein Anmeldefeld.

Wenn ich den .htaccess lösche, kann ich ohne Fehler wieder in den Ordner einsteigen.

Beim Ersetzen der .htacces bekomme ich den Fehler erneut, Immer noch kein Login -Box.

Ich habe versucht, eine neue Reihe von Dateien, Benutzer-/Pass -Kombination und geringfügige Änderungen an .htaccess zu regenerieren, um zu versuchen, eine Reaktionsform zu erhalten.

Ich habe nach Bytemark nachgefragt, beide Dateien sind sauber UTF-8.

Was ist los? Warum bekomme ich keine Eingabeaufforderung mehr?

Wo sollte das Protokoll sein? Ich habe nur einige Zugriffsprotokolle mit nichts Nützlichem in ihnen gefunden.


Standortstandort auf dem Server

/home/labvccom/

/home/labvccom/public_html/admin/.htaccess

AuthName "Restricted Area"
AuthType Basic
AuthUserFile /htpasswords/.htpasswd
AuthGroupFile /dev/null
require valid-user

/home/labvccom/htpasswords/.htpasswd [Benutzer: admin | Pass: Passwort

admin:02yd6IWnPes66

Dies ist die Seite, die ich bekomme, wenn er den Fehler ohne Anmeldeaufforderung auswirkt

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@labvc.com.au and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 mod_fcgid/2.3.5 Phusion_Passenger/2.2.15 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at labvc.com.au Port 80
War es hilfreich?

Lösung

Ihr Browser erinnert sich an den ersten Anmeldeversuch und sendet die Anmeldeinformationen in der Genehmigung Header - Deshalb erhalten Sie keine neue Anmeldeaufforderung.

Versuchen Sie, den Autorisierungs -Cache zu löschen.

Das zugrunde liegende Problem ist höchstwahrscheinlich, wie @openScript.ch vorschlägt.

Andere Tipps

Ich denke, Ihr Weg zur .htpasswd-Datei ist falsch. Wenn es nicht absolut ist, wird es als relativ zur Serverroot behandelt. Versuchen Sie, einen absoluten Weg zu Ihrem .htpasswd-Datei zu verwenden.

Sie müssen Anmeldung/Pass erstellen. Ich habe vor einigen Tagen ein einfaches PHP -Tool erstellt, das Anmeldung/Pass für Sie erstellt. Es ist ein Teil eines anderen meines Projekts ... also habe ich es aus meinem Archiv für Sie extrahiert. Achten Sie darauf, dass unter Windows das Passwort klar gesendet wird ... ist kein Fehler meines Skripts, sondern eine Anfrage von Windows -Servern. Verwenden Sie es also nur im Remote -Hosting mit UNIX, Linux, das Apache läuft. Legen Sie apache-ht.php in den Ordner, den Sie schützen möchten, und führen Sie ihn dann aus. Seien Sie aufgefordert, Benutzer/Pass zu erstellen! Nach dem Abschluss apache-ht.php aus dem Ordner löschen. Sie scheitern, weil Sie versuchen, den relativen Pfad festzulegen. Diese Art von .htaccess braucht den vollen Weg! Ich hoffe das hilft:

apache-ht.php

<?php
  ############################################
  # Created By Alessandro Marinuzzi [Alecos] #
  # apache-ht.php - Version 1.5 - 07/04/2015 #
  # WebSite: ---> http://www.alecos.it/ <--- #
  ############################################
  if ((isset($_POST['username']) && (!empty($_POST['username']))) && ((isset($_POST['password'])) && (!empty($_POST['password'])))) {
    $username = $_POST['username'];
    $password = $_POST['password'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Apache - Username :: Password Generator</title>
<style type="text/css">
@import url(http://fonts.googleapis.com/css?family=Oswald);
@import url(http://fonts.googleapis.com/css?family=Roboto+Condensed);
html {
  display: table;
}
html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}
body {
  background-color: lightgray;
  display: table-cell;
  vertical-align: middle;
  font-family: Oswald, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-style: normal;
  line-height: normal;
  font-weight: normal;
  font-variant: normal;
}
.mainbox {
  border-radius: 7px;
  border: 1px solid gray;
  background-color: darkgray;
  width: 420px;
  height: auto;
  margin-top: 50px;
  margin-bottom: 50px;
  vertical-align: middle;
  text-align: center;
  margin: 0 auto;
  padding: 20px;
}
.title {
  font-family: Oswald, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 24px;
  font-style: normal;
  line-height: normal;
  font-weight: normal;
  font-variant: normal;
  vertical-align: middle;
  text-align: center;
}
.save {
  font-family: Oswald, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 20px;
  font-style: normal;
  line-height: normal;
  font-weight: normal;
  font-variant: normal;
  border-radius: 3px;
  border: 1px solid black;
  background-color: darkviolet;
  cursor: pointer;
  box-shadow: inset -5px 5px 5px rgba(255, 255, 255, 0.15), inset 5px -5px 5px rgba(0, 0, 0, 0.15);
  vertical-align: middle;
  text-align: center;
  padding: 10px;
}
.data {
  font-family: Oswald, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 17px;
  font-style: normal;
  line-height: normal;
  font-weight: normal;
  font-variant: normal;
  vertical-align: middle;
  text-align: center;
}
.doit {
  vertical-align: middle;
  text-align: center;
}
.user {
  font-family: Oswald, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-style: normal;
  line-height: normal;
  font-weight: normal;
  font-variant: normal;
  background-color: #006699;
  border: #C0C0C0 2px solid;
  vertical-align: middle;
  text-align: center;
  border-radius: 3px;
  color: white;
  width: 80px;
  margin: 5px;
}
.pass {
  font-family: Oswald, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-style: normal;
  line-height: normal;
  font-weight: normal;
  font-variant: normal;
  background-color: #006699;
  border: #C0C0C0 2px solid;
  vertical-align: middle;
  text-align: center;
  border-radius: 3px;
  color: white;
  width: 80px;
  margin: 5px;
}
</style>
</head>
<body>
<?php
    if ((substr($_SERVER['DOCUMENT_ROOT'],-1,1) == "/") && (substr($_SERVER['PHP_SELF'],0,1) =="/")) {
      $path = $_SERVER['DOCUMENT_ROOT'] . substr(dirname($_SERVER['PHP_SELF']),1) . "/.htpasswd";
    } else {
      $path = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . "/.htpasswd";
    }
    $tmp1 = fopen(".htaccess", "w");
    $tmp2 = "AuthType Basic\n";
    $tmp2 .= "AuthName \"Restricted Area\"\n";
    $tmp2 .= "AuthUserFile \"$path\"\n";
    $tmp2 .= "Require valid-user\n";
    fwrite($tmp1, $tmp2);
    fclose($tmp1);
    unset($tmp1);
    unset($tmp2);
    if (strtoupper(substr(PHP_OS,0,3) == 'WIN')) {
      $tmp1 = fopen(".htpasswd", "w");
      $tmp2 = "$username:$password\n";
      fwrite($tmp1, $tmp2);
      fclose($tmp1);
      unset($tmp1);
      unset($tmp2);
    } else {
      $tmp1 = fopen(".htpasswd", "w");
      $tmp2 = "$username:" . crypt($password,'$6$rounds=5000$usesomesillystringforsalt$') . "\n";
      fwrite($tmp1, $tmp2);
      fclose($tmp1);
      unset($tmp1);
      unset($tmp2);
    }
    exit("<div class=\"mainbox\">\n<span class=\"title\">Apache - Username :: Password Generated!</span>\n</div>\n</body>\n</html>");
  }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Apache - Username :: Password Generator</title>
<style type="text/css">
@import url(http://fonts.googleapis.com/css?family=Oswald);
@import url(http://fonts.googleapis.com/css?family=Roboto+Condensed);
html {
  display: table;
}
html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}
body {
  background-color: lightgray;
  display: table-cell;
  vertical-align: middle;
  font-family: Oswald, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-style: normal;
  line-height: normal;
  font-weight: normal;
  font-variant: normal;
}
.mainbox {
  border-radius: 7px;
  border: 1px solid gray;
  background-color: darkgray;
  width: 420px;
  height: auto;
  margin-top: 50px;
  margin-bottom: 50px;
  vertical-align: middle;
  text-align: center;
  margin: 0 auto;
  padding: 20px;
}
.title {
  font-family: Oswald, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 24px;
  font-style: normal;
  line-height: normal;
  font-weight: normal;
  font-variant: normal;
  vertical-align: middle;
  text-align: center;
}
.save {
  font-family: Oswald, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 20px;
  font-style: normal;
  line-height: normal;
  font-weight: normal;
  font-variant: normal;
  border-radius: 3px;
  border: 1px solid black;
  background-color: darkviolet;
  cursor: pointer;
  box-shadow: inset -5px 5px 5px rgba(255, 255, 255, 0.15), inset 5px -5px 5px rgba(0, 0, 0, 0.15);
  vertical-align: middle;
  text-align: center;
  padding: 10px;
}
.data {
  font-family: Oswald, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 17px;
  font-style: normal;
  line-height: normal;
  font-weight: normal;
  font-variant: normal;
  vertical-align: middle;
  text-align: center;
}
.doit {
  vertical-align: middle;
  text-align: center;
}
.user {
  font-family: Oswald, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-style: normal;
  line-height: normal;
  font-weight: normal;
  font-variant: normal;
  background-color: #006699;
  border: #C0C0C0 2px solid;
  vertical-align: middle;
  text-align: center;
  border-radius: 3px;
  color: white;
  width: 80px;
  margin: 5px;
}
.pass {
  font-family: Oswald, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-style: normal;
  line-height: normal;
  font-weight: normal;
  font-variant: normal;
  background-color: #006699;
  border: #C0C0C0 2px solid;
  vertical-align: middle;
  text-align: center;
  border-radius: 3px;
  color: white;
  width: 80px;
  margin: 5px;
}
</style>
</head>
<body>
<div class="mainbox">
<span class="title">Apache - Username :: Password Generator</span><br>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<span class="data"><label for="username">Username:</label> <input type="text" class="user" id="username" name="username"></span><br>
<span class="data"><label for="password">Password:</label> <input type="text" class="pass" id="password" name="password"></span><br>
<span class="doit"><input type="submit" class="save" value="Create Username &amp; Password"></span><br>
</form>
</div>
</body>
</html>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top