.htpasswd and .htaccess

Discussion in 'Apache' started by jk111, Jan 31, 2008.

  1. #1
    Ok, so I have the .htaccess file that looks like this placed in the directory I want to password protect.
    AuthName "Secure Area"
    AuthType Basic
    AuthUserFile /path/to/your/directory/.htpasswd
    require valid-user

    Now I used the .htpasswd command and got that file created but now what do I do ?

    Thanks.

    P.s I am using windows apache version 2.2.8
     
    jk111, Jan 31, 2008 IP
  2. boltok

    boltok Active Member

    Messages:
    257
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    78
    #2
    The htpasswd command is used to create a password file (can be any name) and add the username + password to this file.

    Once you've done that and added the "require username" line in your .htaccess, that should be enough and you should get a prompt when you try to access this area from your browser.
     
    boltok, Feb 2, 2008 IP
  3. Jacotus Brededin

    Jacotus Brededin Well-Known Member

    Messages:
    361
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    110
    #3
    Alternatively, you can use an online generator to create your htpasswd file.
    Check the one on Joe's web tools: htpasswd generator
     
    Jacotus Brededin, Feb 3, 2009 IP
  4. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #4
    Place the file somewhere safe and readable by Apache, then add that path in place of the one in this line from what you posted.

    AuthUserFile /path/to/your/directory/.htpasswd
    Code (markup):
    For instance

    AuthUserFile "c:/www/auth/.htpasswd"
    Code (markup):
     
    joebert, Feb 3, 2009 IP