Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Posts
    6
    Rep Power
    0

    Request for help with .htpasswd and .htaccess files


    Hi all,

    I am trying to create a passworded folder on my web server using Apache .htaccess and .htpasswd.
    I just keep getting the prompt to log in and when I put in the user name and password I specified in those files, my login always returns unsuccessful.
    Here are the contents of the files.
    Content of .htaccess file:
    -----------------------------------------------------------------------
    AuthType Basic
    AuthUserFile "/htdocs/…./.htpasswd"
    AuthName “Enter valid username and password!”
    require valid-user
    ------------------------------------------------------------------------

    Content of the .htpasswd file:
    --------------------------------------------
    myname: abcdef123
    --------------------------------------------

    In a bid to resolve the problem, I have used various encryption tools to encrypt the password in the .htpasswd and I have used these:
    myname:1$.2iDtIZW/cg
    myname:$apr1$6qpmb1a3$H10LASGeIvQVfslXOLn4G1
    myname:$apr1$XhKhUnQT$tqaPs6J9qBZMJsipFQnnq.

    …but I got the same result.

    In case it will help, my Apache Version Number is 2.2.3.
    Why can't I log in?
    Any help suggestions will be appreciated.

    Thanks.
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,443
    Rep Power
    4539
    Try putting the complete disk path to the .htpasswd file in your .htaccess
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2009
    Posts
    335
    Rep Power
    246
    None of those encryptions look right for the username and password you provide... using an online tool I get
    myname:hY/QrK1CTcOVw
    try this generator.... http://www.kxs.net/support/htaccess_pw.html
    Free MP3 Dance Music Downloads

    To err is human; To really balls things up you need Microsoft!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Posts
    6
    Rep Power
    0
    Thanks a lot @1DMF, I used the tool/generator you referred me to to create a new password. I copied the user name and password combination that was generated to the .htpasswd file, but got the same result.
    'Still doesn't log me in.

    @Doug G
    I had put the complete disk path to the .htpasswd file in the .htaccess file.
    "/htdocs/…./.htpasswd" was just a short form for posting my question.
  8. #5
  9. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2009
    Posts
    335
    Rep Power
    246
    Do you get a specific error?

    What file attributes do you have on the .htaccess and .htpasswd files?
    Free MP3 Dance Music Downloads

    To err is human; To really balls things up you need Microsoft!
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Posts
    6
    Rep Power
    0
    Thanks 1DMF.
    THere is no error message given. The login screen just reappears.
    How do I check the permissions on the files?
    I use a windows desktop/laptop and can't at this time, set the permissions of the files using windows (since I'm using linux hosting to host the site).

    I tried to check for the file permissions from the FTP interface, but the .htaccess file and the .htpasswd file are not being displayed.

    Is there a way for me to check the file permissions on the shared linux hosting server?
    What should the file permissions of these files be?

    THanks
  12. #7
  13. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2009
    Posts
    335
    Rep Power
    246
    I use FileZilla as an FTP client where I can upload my files and set file attributes.

    If you cannot see your .htaccess file, how are you able to edit it or change it?

    I have 644 set against mine and it seems to work fine.

    I assume you have the .htaccess file in the same folder as the one you are trying to password protect?
    Free MP3 Dance Music Downloads

    To err is human; To really balls things up you need Microsoft!
  14. #8
  15. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,443
    Rep Power
    4539
    Have you checked your http log files? Usually there will be something in the apache error log when a .htaccess auth request fails.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  16. #9
  17. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,127
    Rep Power
    4304
    Originally Posted by redhat19
    I tried to check for the file permissions from the FTP interface, but the .htaccess file and the .htpasswd file are not being displayed.
    You may need to configure your FTP client (the Windows program you're using) to display hidden files. (On Linux and Unix systems, the "." at the start of a file name indicates that it's a hidden file.)
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Posts
    6
    Rep Power
    0
    Hi Guys, thanks for all the help.
    @Doug G: Is it possible to check the http log files on my account on a shared hosting server? (cos that’s what I’m using).
    @1DMF: Yes, I have the .htaccess file and the .htpasswd file in the same folder.
    I used FileZilla too and couldn’t see the .htaccess and .htpasswd files… until I read @Kravvitz’s post, which made me know I could force the FTP client to display hidden files on the server.
    @Kravvitz: Thanks for your reply. I didn’t know I could force the FTP client to display hidden files. When I eventually did, I was able to view the files, but…
    The file permissions on my .htaccess and .htpasswd files were 664, like @1DMF recommended, but it was still not working. I have changed the permissions around back and forth and its still not working. What’s supposed to be the recommended file permissions on the .htpasswd file? (Although, in trying out all the permissions settings, I’m almost sure I have already tried it..and still couldn’t get it to work).
  20. #11
  21. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2009
    Posts
    335
    Rep Power
    246
    without stating the obvious, but if you have the right permission (644) , you have no mod_rewrites or other stuff affecting the .htaccess file
    Code:
    AuthName "Your Auth Name"
    AuthType Basic
    AuthUserFile /your/full/path/public_html/etc../.htpasswd
    require valid-user
    and the .htpasswd
    Code:
    USERID:encryptedpwd
    Are you sure you are typing userid & password in the correct case as *nix is case sensitive?

    I can't think of anything else, it worked 1st time for me on my shared hosting?
    Free MP3 Dance Music Downloads

    To err is human; To really balls things up you need Microsoft!
  22. #12
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Posts
    6
    Rep Power
    0
    Hi 1DMF

    Thanks for all the help.
    Yes, I was typing the encrypted password with all the cases. I even copied and pasted.
    After reading your post, I realized I was doing everything right..
    So, I tried this:
    USERID:

    (i.e I left the password field blank)

    ..and it worked.

    So, I guess its something to do with the kind of encryption I'm using.
    ..and I was using the encryption tool at the URL you had pointed me to earlier.
  24. #13
  25. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2009
    Posts
    335
    Rep Power
    246
    I'd check the case you typed when using the encryption tool for both UserID and password.

    It might be as simple a mistake as that?
    Free MP3 Dance Music Downloads

    To err is human; To really balls things up you need Microsoft!
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    876
    Rep Power
    275
    one other thing is to make sure, in your ftp client, that you upload your .htpasswd and .htaccess files as ASCII and not BINARY.
    Most ftp clients should take of this for you, but, its worth mentioning I think.
  28. #15
  29. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2009
    Posts
    335
    Rep Power
    246
    So was this resolved?

    Do you have any feedback?

    Can you help others with similar problems by letting them know what you did?
    Free MP3 Dance Music Downloads

    To err is human; To really balls things up you need Microsoft!
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo