Wenn ich dann nach der Anleitung auf der Website
http://httpd.apache.org/docs/1.3/howto/auth.html vorgehe, kann ich mit dem Befehl:
htpasswd -c /usr/local/apache/passwd/passwords admin
keine Datei anlegen (Fehler: cannot create file /user/../passwords
Soweit richtig, da die Pfadanweisung aus dem Unix bereich kommt
wenn ich den Befehl auf htpasswd -c /passwords admin
Analyse:
Du bist mittels Terminalfenster (DOSbox) in \xampp\apache\bin\ und führst nun den befehl htpasswd aus.
mit
-c wird das erstellen eines filename deklariert.
mit
/passwords gibt du einmal einen pfad und den namen der datei an. Da aber Windows den Pfad "/" so nicht kennt dürfte er versuchen eine datei mit den namen "passowrds" entweder im \xampp\apache\bin oder auf c:\ abzulegen.
mit
admin vergibt man den Namen den man eigentlich noch mit einem Passwort versehen möchte.
Hilfestellung von htpasswd.exe
C:\xampp\apache\bin>htpasswd --help
Usage:
htpasswd [-cmdpsD] passwordfile username
htpasswd -b[cmdpsD] passwordfile username password
htpasswd -n[mdps] username
htpasswd -nb[mdps] username password
-c Create a new file.
-n Don't update file; display results on stdout.
-m Force MD5 encryption of the password (default).
-d Force CRYPT encryption of the password.
-p Do not encrypt the password (plaintext).
-s Force SHA encryption of the password.
-b Use the password from the command line rather than prompting for it.
-D Delete the specified user.
On Windows, NetWare and TPF systems the '-m' flag is used by default.
On all other systems, the '-p' flag will probably not work.
Folglich solte dein aufruf (ausgehend das du in der DOSbox wie oben beschrieben bist)
- Code: Select all
htpasswd -c c:\pfad_des_xampps\pfad_des_Verzeichnisses_wohin_die _passwort_datei_abgelegt_werden_soll\passwortdateiname NAME PASSWORT
Und in das Verzeichnis das geschützt werden soll, kommt dann eine
.htaccess datei, die dann eine deklaration besitzt das dann als Pfad die Passwortdatei bekommt.
Würde in deinem Fall ungefähr so aussehen. ( .htaccess )
- Code: Select all
AuthType Basic
AuthName "Ein geschützter Bereich"
AuthUserFile c:\pfad_des_xampps\pfad_des_Verzeichnisses_wohin_die _passwort_datei_abgelegt_wurde\passwortdateiname
require valid-user
<Limit GET>
Order allow,deny
Allow from all
Deny from none
</Limit>
<Limit POST,PUT>
Order deny,allow
Deny from all
Allow from localhost
</Limit>
Jetzt sollte beim aufruf
http://localhost/geschützer-bereich eine Authetifikation stattfinden.