Link to home
Start Free TrialLog in
Avatar of ellandrd
ellandrdFlag for Ireland

asked on

htaccess not working

i want to protect this directory:

w:/apache/domain/htdocs/prelease

so ive placed the following .htaccess and .htpasswd files in:

w:/apache/domain/htdocs/prelease/.htaccess
w:/apache/domain/htdocs/prelease/.htpasswd

In my .htaccess file i have this:

AuthName "Restricted Area"
AuthType Basic
AuthUserFile w:/apache/domain/htdocs/prelease/.htpasswd
AuthGroupFile /dev/null
require valid-user

btw, the w:/apache/domain/htdocs is a virtual host

Do i have to modify/add anything to my httpd.conf file?
Avatar of ravenpl
ravenpl
Flag of Poland image

> Do i have to modify/add anything to my httpd.conf file?
Depends - and for that You have to look into apache's errorlog

To use any directive in .htaccess You have to be allowed to Override the value it changes. eg.
to use AuthName You have to be allowed to override AuthConfig, therefore in httpd.conf You need
<Directory w:/apache/domain/htdocs/prelease> # this or any parent directory
 AllowOverride +AuthConfig
</Directory>
Refer http://httpd.apache.org/docs/2.0/mod/core.html#authname
Avatar of ellandrd

ASKER

ok but currently i have this setup:

<Directory w:/apache/domain/htdocs>
  Order deny,allow
  Allow from All
  Options Indexes
</Directory>

do i need this:

<Directory w:/apache/domain/htdocs/prelease>
 AllowOverride +AuthConfig
</Directory>

too?? as i only want to protect the prelease directory inside htdocs of w:/apache/domain
Change current to
<Directory w:/apache/domain/htdocs>
  Order deny,allow
  Allow from All
  Options Indexes AuthConfig # every .htaccess in w:/apache/domain/htdocs and subdirs may change AuthConfig
</Directory>

or add the new code - but after the above (order of <directory> declarations have meaning), so only Directory w:/apache/domain/htdocs/prelease is allowed to use AuthConfig in it's .htaccess

Hope i'm clear.
>>Hope i'm clear.

no - sorry

like this:

<Directory w:/apache/domain/htdocs>
  Order deny,allow
  Allow from All
</Directory>

<Directory w:/apache/domain/htdocs/prelease>
  Order deny,allow
  Allow from All
  Options Indexes AuthConfig
</Directory>
ASKER CERTIFIED SOLUTION
Avatar of ravenpl
ravenpl
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ok.

and the path in my .htaccess file is correct right?

AuthName "Restricted Area"
AuthType Basic
AuthUserFile w:/apache/domain/htdocs/prelease/.htpasswd
AuthGroupFile /dev/null
require valid-user
Yes
> AuthGroupFile /dev/null
is it working under windows ?
ok i added what you said and removed the AuthGroupFile and now apache failed to restart...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
nope - apache still wont start for me again
it is this:

<Directory w:/apache/domain/htdocs/prelease>
 AuthConfig
 Options +AuthConfig
</Directory>

and not this:

<Directory w:/apache/domain/htdocs/prelease>
 Options +AuthConfig
</Directory>

 right?  your # comments are overlapping and confusing me to what is inside the directory and what is not!
The second one - literally as I provided.
> nope - apache still wont start for me again
and what is the error message?
MMmm ok i added this:

<Directory w:/apache/sdwebdesign/htdocs/prelease>
      AllowOverride AuthConfig
</Directory>

and i got prompted for username and password and after i entered them i got page not found??

but inside the prelease directory, is index.php so shouldnt it just pick that up?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
now after i enter my password and username i get:

"Server Error" from my custom error pages...
my error logs show:

[Fri Sep 22 14:28:54 2006] [error] [client 127.0.0.2] (OS 3)The system cannot find the path specified.  : Could not open password file: W:/Apache/domain/htdocs/prelease/.htpasswd
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
my path was wrong inside my .htaccess file, but now it keeps promtping me for user/password combo... and when i type  it in, it wont accept them...
im getting:

[Fri Sep 22 14:46:12 2006] [error] [client 127.0.0.2] user seandelaney: authentication failure for "/prelease": Password Mismatch

i used dynamic drive to create my username and password?  would that site have created it wrong?  where or how can i create my hashed password that will "work"...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ive just copied and pasted it in
the 'htpasswd' utility worked great!!