views:

382

answers:

2

I'm trying to protect a folder with Digest Authentication through a .htaccess file:

AuthType Digest
AuthName "Restricted Area"
AuthUserFile /web/htdocs/www.domain.com/.../.htdigest

Require valid-user

I've created the file of passwords with the comand "htdigest". All works fine on my local server ... but not on my remote server (hosted website)! The browser shows the login panel even if I enter a correct password!

On the remote server PHP is running as CGI not as a module of Apache ... should be this the cause? Is there some workaround?

Thanks in advance!


EDIT: A Basic Authentication with .htaccess works fine on the same remote server!

A: 

If the script is running as CGI, that means it is running as the local user, not as www, which is probably the problem, yes. Is CGI the only option?

Anthony
Thanks for your reply! Yes, CGI it's the only option, I can't modify the server configuration to load php as an Apache module!
BitDrink
Wait, do you mean ALL of php? How are you even running the script at all?
Anthony
I think that I've confused your ideas! What I'm trying to do is to protect with Digest Authentication a simple HTML page in a directory. I palced a .htaccess (with the code above) and a .htdigest files on the same folder of the HTML page! But when I try to login with correct credentials, the browser ask me to enter again my credentials! All works fine on my local server (where PHP is installed as a module of Apache) but not on my remote server (where PHP is running as CGI)..so I thought that the cause should be the server configuration...but the hosting service don't let me modify the setting!
BitDrink
A: 

The code above is missing the AuthDigestDomain directive, about that the documentation says:

This directive should always be specified and contain at least the (set of) root URI(s) for this space. Omitting to do so will cause the client to send the Authorization header for every request sent to this server. Apart from increasing the size of the request, it may also have a detrimental effect on performance if AuthDigestNcCheck is on.

However, I've definitely solved the problem by enabling the Apache module mod_auth_digest instead of the module mod_digest.

BitDrink