Question

Je suis en train de protéger un dossier en utilisant '.htaccess' et' .htpasswd ».

http://www.tools.dynamicdrive.com/password/ générer les fichiers.

les Copié dans les dossiers correspondants.

Quand je tentais d'accéder au dossier protégé, Je suis une connexion rapide.

Détails d'entrée de connexion incorrectes, à la page s'envoyé d'erreur.

Toutes les bonnes.

Maintenant, sans aucun changement, je revisite la page pour essayer de se connecter à nouveau pour accéder au dossier protégé, et il jette juste une erreur, il n'y a pas de boîte de connexion.

Si je supprime le .htaccess, je peux entrer dans le dossier à nouveau sans erreur.

En remplaçant les .htaccess, je reçois à nouveau l'erreur, toujours pas de boîte de connexion.

J'ai essayé de régénérer un nouvel ensemble de fichiers, l'utilisateur / combo passe, et de légères modifications .htaccess juste pour essayer obtenir une certaine forme de retour de réponse.

Je l'ai vérifié pour tous les BYTEmark, les deux fichiers sont UTF-8 propres.

Que se passe-t-il? Pourquoi je ne reçois pas une invite plus?

Sur une note de côté, où le journal doit être? Tout ce que je réussi à trouver des journaux était d'accès avec rien d'utile en eux.


emplacement du site sur le serveur

/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 utilisateur [: admin | passe: Mot de passe]

admin:02yd6IWnPes66

Ceci est la page que je reçois quand il jette l'erreur avec NO connexion rapide

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
Était-ce utile?

La solution

Votre navigateur se souvient de la première tentative de connexion et d'envoyer les informations d'identification dans la section en-tête autorisation -. qui est la raison pour laquelle vous ne recevez pas une nouvelle connexion rapide

Essayez de vider le cache d'autorisation.

Le problème sous-jacent est le plus probable que @ openscript.ch suggère.

Autres conseils

Je pense que votre chemin vers le fichier .htpasswd-est erroné. Si ce n'est pas absolue, elle est traitée comme par rapport au ServerRoot. Essayez d'utiliser un chemin absolu à votre .htpasswd-fichier.

Vous devez créer login / pass .htaccess dans le dossier que vous voulez protéger ... sinon l'astuce ne fonctionnera pas comme voulu! J'ai créé il y a un outil simple php quelques jours qui crée login / pass pour vous. Il est une partie d'une autre mon projet ... alors je l'ai extrait de mes archives pour vous. Faites attention que sous Windows le mot de passe est envoyé clair ... est pas un bug de mon script, mais une demande par les serveurs Windows. Il faut donc utiliser que dans l'hébergement à distance avec unix, linux apache en cours d'exécution. Mettez-apache ht.php dans le dossier que vous souhaitez protéger, puis l'exécuter. Invité à créer utilisateur / pass! Après suppression apache done-ht.php du dossier. Vous ne parvenez pas parce que vous essayez de définir le chemin relatif. Ce genre de .htaccess a besoin chemin complet! J'espère que cette aide:

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>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top