Authenticated directory listing

Authenticated directory listing

Posted by: EnPa
Posted on: 2007-01-31 04:59:00

Hi,

I am hosting some pages at DH.
I know how to block directory listing for everyone:

"Options -Indexes" in the .htaccess file.

How can I make the server ask for authentication (like .htpasswd) and allow listing only on successful login?

Let me (try to) explain what I want to do...
If I go to http://mydomain.com/some-directory/ I want to be prompted for a password.
If the password is correct, I get the standard directory listing generated by Apache.
If the password is wrong I should get a 403 status code or an empty page.

BUT: the files in the directory must be accessible for everybody.
If I type http://mydomain.com/some-directory/some-file.jpg I should be able to see the pic without being prompted for a password.

I cannot use IP-based solutions.

Thank you in advance
EnPa

P.S.: sorry for my bad english...

Re: Authenticated directory listing

Posted by: nathan823
Posted on: 2007-01-31 05:03:00

Does this help? http://wiki.dreamhost.com/index.php/Htaccess#Authentication_examples

Re: Authenticated directory listing

Posted by: EnPa
Posted on: 2007-01-31 05:31:00

Not really...

Here is what I want to do in "pseudo-code" ;-)

Someone goes to mydomain.com/directory/
Ask for password
If password wrong ---> Options -Indexes
Else ---> Options +Indexes

Nothing else!
Access to files should always be granted!

EnPa

Re: Authenticated directory listing

Posted by: nathan823
Posted on: 2007-01-31 06:23:00

I'm not familiar with htaccess. But I don't think you can do this with htaccess. It seems you need two htaccess files in two folders with the different settings.

If I understand correctly (I've mis-understood the questinos some time before), you want to apply different settings to users. You can use PHP authentication fuction to ask use to enter a password and redirect them to different folders. However, this may not be the solution you are looking for.

Let's see what the htaccess experts suggest.

Save $97 (max discount) on dreamhost plans by using promo code: 97CRAZY.Edited by nathan823 on 01/31/07 06:26 AM (server time).

Re: Authenticated directory listing

Posted by: extras
Posted on: 2007-01-31 07:24:00

I've not tested this, but it may work using <files>


<Files "">
#You put your Auth things here

</Files>

By specifying Auth section to be applicable only to files with no name, it should only work on the directory = directory linsting.

Please try and let us know.


.*.*.* I'd be happier if DH had free shared SSL and redundant server setup. *.*.*.
http://Hostwick.com/

Re: Authenticated directory listing

Posted by: EnPa
Posted on: 2007-01-31 07:56:00

Thank you, Extras!

It works!

Thank you very much!

EnPa

Re: Authenticated directory listing

Posted by: extras
Posted on: 2007-01-31 08:52:00

Your welcome.
And thank you for testing and reporting back. :)


.*.*.* I'd be happier if DH had free shared SSL and redundant server setup. *.*.*.
http://Hostwick.com/

Tags: directory listinghtaccess filemydomainthank you in advanceempty pagehtpasswdtry to explainauthenticateddhindexesapacheip