Development .htaccess and .htpasswd problems

Discussion in 'Software' started by Lazlow, 27 Oct 2006.

  1. Lazlow

    Lazlow I have a dremel.

    Joined:
    8 Aug 2003
    Posts:
    1,464
    Likes Received:
    0
    I'm having problems with trying to restrict access to a directory on my webserver.

    I've spent some time on Google, looking at various tutorials which show how to password protect a directory using .htaccess and .htpasswd - but every time I go to login, the username and password don't work.

    My .htaccess looks like this:
    Code:
    AuthName "Admin Area"
    AuthType Basic
    AuthUserFile /home/mjlazlow/public_html/admin/.htpasswd
    Require valid-user
    And is stored in /home/mjlazlow/public_html/admin/

    My .htpasswd looks like this:
    Code:
    username:password
    And is stored in the same location. I will move it outside of the public_html directory once I know that it works correctly.

    Try it yourself, enter username as the username and password as the password. Any suggestions as to why it isn't working? It seems to not be picking up the username/password from the file.
     
  2. trigger

    trigger Procrastinator

    Joined:
    22 Mar 2004
    Posts:
    1,097
    Likes Received:
    30
    I think the password should be hashed shouldn't it, rather than plaintext, so your .htpasswd should be:
    Code:
    username:sp4a40h.B/C4.
     
  3. hitman012

    hitman012 Minimodder

    Joined:
    6 May 2005
    Posts:
    4,877
    Likes Received:
    19
    As above - it needs to be hashed. Use this page to generate the necessary combination.
     
  4. Lazlow

    Lazlow I have a dremel.

    Joined:
    8 Aug 2003
    Posts:
    1,464
    Likes Received:
    0
    I'll try that asap and get back to you with an answer!
     
  5. cpemma

    cpemma Ecky thump

    Joined:
    27 Nov 2001
    Posts:
    12,328
    Likes Received:
    55
    I don't know if it makes the slightest difference, but mine looks like
    Code:
    AuthUserFile /path/.htpasswd
    AuthName "Members only area"
    AuthType Basic
    <Limit GET POST>
    require valid-user
    </Limit>
    
    with the hashed password file as generated by a similar link to hitman012's. All greek to me, I got the method from the host's forum. :)
     
  6. Lazlow

    Lazlow I have a dremel.

    Joined:
    8 Aug 2003
    Posts:
    1,464
    Likes Received:
    0
    OK, I've encrypted the password using the link Hitman012 gave me and altered my .htaccess to resemble cpemma's, but it's still giving a 401 error:

    Code:
    AuthUserFile /home/mjlazlow/public_html/admin/.htpasswd
    AuthName "Admin Area"
    AuthType Basic
    <Limit GET POST>
    require valid-user
    </Limit>
    Any ideas? Could it be something on my host has disabled, which is preventing it from working? I've used .htaccess files in the past and they all work fine (redirects, class B etc.)
     

Share This Page