.htaccess file not working

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

.htaccess file not working

Post by Burrito »

I'm a complete friggin newb to *nix and a relative newb to apache. I have successfully set up an .htaccess file on a windows box with apache to restrict access to a folder and am trying right now to do the same on a *nix box with no success.

here is what my .htaccess file looks like:

Code: Select all

AuthName "restricted database"
AuthType Basic
AuthUserFile /usr/local/httpd/users

require valid-user
I used htpasswd to create my users file and it worked fine

I also changed the AllowOverride directive in httpd.conf to AuthConfig from none.

restarted apache and tried to access a file in my folder with the .htaccess file and it let me right through...what am I missing?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

I've also tried using the standard file name .htpasswd instead of users....no luck
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

Image
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

Image Image Image

sorry to keep bumping this but I really need a resolution here and I'm at a complete dead end...
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Windows doesn't like files starting with a .

Try putting a few characters in front of it and changing your apache config file to reflect the change. Then restart apache.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

this is on a *nix box...not windows.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Oooh I saw windows and could have sworn... anyway, it's gotta be something in the apache config file... If the file is there and formatted correctly there is no reason why it shouldn't work... Not that I can think of anyway..

Unless it's a permission's issue? Can apache "read" the file?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I am not that proficient in Apache to know the exact directives, but this thread had some decent information;

http://www.dynamicdrive.com/forums/arch ... -8592.html

Also, the Apache tutorial on .htaccess has some good information.
Also, are the file permissions for the .htaccess file correct? And is it in the folder that you want to protect? I know those are basic questions, but it never hurts to ask.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

that's just it...I don't think it's even reading the .htaccess file, but I don't know a way I can make that determination for sure.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

Everah wrote: Also, are the file permissions for the .htaccess file correct? And is it in the folder that you want to protect? I know those are basic questions, but it never hurts to ask.
yes (777) and yes :)
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Have you got the correct setting for the AllowOverride bits of the httpd.conf?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

yup, I have it set for 'AuthConfig'
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

I normally have this line

Code: Select all

AuthUserFile /usr/local/httpd/users
setup like this

Code: Select all

AuthUserFile /usr/local/httpd/users/.htpasswd
This is one of mine that i use

Code: Select all

AuthUserFile /home/virtual/site412/fst/var/www/.htpasswd
AuthGroupFile /home/virtual/site412/fst/var/www/.htgroup
AuthName "ClientName"
AuthType Basic
<Limit GET>
require group  ClientName
</Limit>
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

yeah if you read my second post, I've tried that as a file name as well...no luck:

I've now tried creating another <Directory> in my httpd.conf file and pointed it explicitly to the location of the folder in question and used AllowOverride AuthConfig...still no go! GRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR!
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Another simple question... is the folder name spelled the same (case-wise) in the .htaccess as it is in the folder tree?
Post Reply