The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> System Administration
> Apache Development
|
general - Request for help with .htpasswd and .htaccess files
Discuss Request for help with .htpasswd and .htaccess files in the Apache Development forum on Dev Shed. Request for help with .htpasswd and .htaccess files Apache Development forum discussing HTTP Server general topics, configuration, and modules. Apache is an open source web server that runs on multiple platforms.
|
|
 |
|
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

December 6th, 2011, 02:49 AM
|
|
Registered User
|
|
Join Date: Dec 2011
Posts: 6
Time spent in forums: 1 h 46 m 41 sec
Reputation Power: 0
|
|
|
general - 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.
|

December 6th, 2011, 05:21 PM
|
|
|
|
Try putting the complete disk path to the .htpasswd file in your .htaccess
__________________
======
Doug G
======
It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi
|

December 7th, 2011, 05:43 AM
|
 |
Contributing User
|
|
|
|
None of those encryptions look right for the username and password you provide... using an online tool I get
try this generator.... http://www.kxs.net/support/htaccess_pw.html
|

December 7th, 2011, 11:11 AM
|
|
Registered User
|
|
Join Date: Dec 2011
Posts: 6
Time spent in forums: 1 h 46 m 41 sec
Reputation 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.
|

December 7th, 2011, 12:25 PM
|
 |
Contributing User
|
|
|
|
|
Do you get a specific error?
What file attributes do you have on the .htaccess and .htpasswd files?
|

December 8th, 2011, 02:13 AM
|
|
Registered User
|
|
Join Date: Dec 2011
Posts: 6
Time spent in forums: 1 h 46 m 41 sec
Reputation 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
|

December 8th, 2011, 05:14 AM
|
 |
Contributing User
|
|
|
|
|
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?
|

December 8th, 2011, 10:36 AM
|
|
|
|
Have you checked your http log files? Usually there will be something in the apache error log when a .htaccess auth request fails.
|

December 8th, 2011, 03:26 PM
|
 |
CSS & JS/DOM Adept
|
|
Join Date: Jul 2004
Location: USA
|
|
Quote: | 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.)
|

December 9th, 2011, 05:21 AM
|
|
Registered User
|
|
Join Date: Dec 2011
Posts: 6
Time spent in forums: 1 h 46 m 41 sec
Reputation 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).
|

December 9th, 2011, 06:52 AM
|
 |
Contributing User
|
|
|
|
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?
|

December 9th, 2011, 07:12 AM
|
|
Registered User
|
|
Join Date: Dec 2011
Posts: 6
Time spent in forums: 1 h 46 m 41 sec
Reputation 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.
|

December 9th, 2011, 03:51 PM
|
 |
Contributing User
|
|
|
|
|
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?
|

December 9th, 2011, 04:48 PM
|
|
|
|
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.
|

December 15th, 2011, 05:24 AM
|
 |
Contributing User
|
|
|
|
|
So was this resolved?
Do you have any feedback?
Can you help others with similar problems by letting them know what you did?
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|