Forum Moderators: phranque

Message Too Old, No Replies

.htaccess Not Working

Can't seem to find password file

         

Jills2001

4:10 am on Apr 4, 2005 (gmt 0)

10+ Year Member



Hi all,

I am fairly new to Apache and am stumped on a problem I have come up against when trying to configure Apache to password protect a directory using .htaccess.

I have restricted access to certain files in a directory using the "require valid-user" directive. The .htaccess file is as follows:


# bin/.htaccess
AuthName 'Enter name and password'
AuthType Basic
AuthUserFile /usr/dev/TeamWebsite/twiki/data/passwords
ErrorDocument 401 /twiki/bin/oops/TWiki/TWikiRegistration?template=oopsauth
<Files ~ "[^/]*\.html$">
SetHandler blabla
allow from all
</Files>
<Files "edit">
require valid-user
</Files>

I have then created the password file from the command line as follows:


/usr/apache/bin/htpasswd -c /usr/dev/TeamWebsite/twiki/data/passwords Jill
New password: test
Re-type new password: test
Adding password for user Jill

The password file seems to be created correctly. Then, when I try to access the restricted page (http://foddev1:8080/twiki/bin/edit) it asks me for my password and even though I enter the *correct* login details it does not let me in. It just asks me for my password three times then throws an error. The Apache error log states the following:


[Mon Apr 4 12:04:48 2005] [error] [client 10.216.60.5] user Julie not found: /twiki/bin/edit/Main/WebHome

...It does not seem to be able to see my password file...?

If I delete the "require valid-user" line in the .htaccess file and replace it with "Allow from 10.216.60.5" (ie, my IP address) it grants me access.

Is anyone able to suggest to me why this might be occurring? I have been told that it is probably to do with my Apache configuration, but am not sure where to start trouble-shooting this. An exerpt from my httpd.conf file is below:


AccessFileName .htaccess
ScriptAlias /twiki/bin/ "/usr/dev/TeamWebsite/twiki/bin/"
Alias /twiki/ "/usr/dev/TeamWebsite/twiki/"
<Directory "/usr/dev/TeamWebsite/twiki/bin">
AllowOverride All
Options +ExecCGI
SetHandler cgi-script
Allow from all
</Directory>
<Directory "/usr/dev/TeamWebsite/twiki/pub">
Options FollowSymLinks +Includes
AllowOverride None
Allow from all
</Directory>
<Directory "/usr/dev/TeamWebsite/twiki/data">
deny from all
</Directory>
<Directory "/usr/dev/TeamWebsite/twiki/templates">
deny from all
</Directory>

Any help would be really appreciated. If you need any other info from my httpd.conf file I will be happy to provide it.

Thanks in advance,

Jill

jdMorgan

7:26 pm on Apr 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Jill,

Welcome to WebmasterWorld!

> [Mon Apr 4 12:04:48 2005] [error] [client 10.216.60.5] user Julie not found: /twiki/bin/edit/Main/WebHome

Since this is neither the correct auth file, nor the correct user, I don't know what to tell you. It appears that your .htaccess code is not being invoked.

On the other hand, you've got AllowOverride set to allow per-directory (.htaccess) settings, so it should be working.

I'd recommend re-checking the authfile path against all of your aliases.

Jim

Jills2001

10:17 pm on Apr 4, 2005 (gmt 0)

10+ Year Member



Hi,

Thanks for your reply. Sorry, I seemed to have copied a wrong error message in the error file. The correct one was this:


[Mon Apr 4 12:04:48 2005] [error] [client 10.216.60.5] user Jill not found: /twiki/bin/edit/Main/WebHome

So the user is actually correct.

I do see what you're saying though about the file path on the error message not being the path to my passwords file. Should the error state the path it is looking in to find the authentication details?

In the meantime, I will try and find if there are any aliases diverting Apache from the location of my password file. Is there an easy way to do this, other than manually scanning through the httpd.conf file?

Thanks again for your help,

Jill

onyx

5:32 pm on Apr 19, 2005 (gmt 0)

10+ Year Member



Jill,
If it makes you feel any better, I am having the exact same problem as you. I ended up using your comment of allowing a specific IP to grant access. I am not sure what else to try... Anyone else have any other suggestions? If you would like to see the details of my problem (even though the problem is exactly as described by Jill), I will be happy to post them. Just let me know.

- Onyx

jd01

8:05 pm on Apr 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Jills,

This is not my forte, but it looks like you need to recheck your configuration... (best guess, had the same problem about a year ago and don't remember exactly what I did to fix it.)

There are a couple of things I am seeing...
1.
this: /usr/dev/TeamWebsite/twiki/data/passwords

is not this: /twiki/bin/edit/Main/WebHome

So, somewhere there is a disconnect in the location of your password file. I think this can either come from the httpd.conf file or a file called .htmaster.

(My guess is there is a configuration file at the end of this path /twiki/bin/edit/Main/WebHome that existed before you started, and is directed to for the location of the password files.)

2. normally a basic auth password file is called .htpasswd, not passwords... I would double check all of my routing and use what the default is, until everything was working... EG I would change any and all references of passwords to .htpasswd until it all worked.

I really think I remember #1 being the problem with mine...

Anyway just a couple of ideas.

Justin

onyx

10:13 pm on Apr 19, 2005 (gmt 0)

10+ Year Member



Justin,
FYI, since my first post, I have corrected my problem and things are working. :-) My problem was not related to anything stated on this forum.

About the comments you most recently posted, I agree with your 1). Jills' logs show a different location for the Apache AuthUser password file than what she created with the line below:
/usr/apache/bin/htpasswd -c /usr/dev/TeamWebsite/twiki/data/passwords Jill

As far as what you stated for 2), that is not true. By convention, AuthUser password files are called .htpasswd. It is derived from the command that creates them, 'htpasswd'. But the file does not need to be called that. It can be called anything as long as it is referenced in a directive, either in the Apache configuration file or in a .htaccess file.

- Onyx

jd01

10:28 pm on Apr 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Onyx,

Glad you got yours working...

Maybe I can clarify for later users, etc.

In number 2 I was saying I would use the default, until I had a working knowledge and understanding of what was going on, this way I would know there was not something minor I was missing or overlooking...

I often revert to defaults to trouble shoot issues, because in many cases it eliminates some of the possible operator (me) errors. Then after I have the issue resolved, I can begin to 'play' with what I feel like.

I did not mean to imply that it could not ever be changed to passwords or even doodle if that's what was desired, just that sometimes it is more efficient to make it work first, then customize...

Justin

binu

8:53 am on May 3, 2005 (gmt 0)



Hi friends,
Me too new to htacces and I am finding the same problem that Jill faced. So I would like to know how to reslove this problem.

Waiting for ur response.
Thanking you,
Binu.

[edited by: jdMorgan at 2:30 pm (utc) on May 3, 2005]
[edit reason] No emails/IM per TOS. [/edit]

onyx

9:03 am on May 3, 2005 (gmt 0)

10+ Year Member



Binu,
Post as much information about the problem as you can here (similar to what Jill did), and we will see if we can help.

- Onyx