Forum Moderators: phranque

Message Too Old, No Replies

using .htaccess to generate index

How can you use .htaccess to generate a directory index on localhost

         

hwttdz

5:14 pm on Jul 7, 2005 (gmt 0)

10+ Year Member



I'm trying to get apache to generate an index for directories on my localhost but so far all I can get is a 403 error (forbidden). There was no .htaccess file in my webroot so I made one and right now it has one line being

options +indexes

I don't even really know where to go from here. Does anyone have any suggestions, thanks.

coopster

5:46 pm on Jul 7, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, hwttdz.

In order to do so, you have to allow per-directory overrides.

Apache Tutorial: .htaccess files [httpd.apache.org]
AllowOverride [httpd.apache.org]

hwttdz

6:08 pm on Jul 7, 2005 (gmt 0)

10+ Year Member



I've got up until adding icons, I'm in httpd.conf and trying to add under

<Directory />

DefaultIcon ./icons/unknown.xbm
AddIconByType (IMG,/icons/image.gif) image/*
AddIconByType (SND,/icons/sound.gif) audio/*
AddIconByType (TXT,/icons/text.gif) text/*

where I have the icons folder in www\icons and webroot is my localhost directory and webroot is in www\webroot. I'm not getting any pictures to show up, and the folders have [dir] next to them and all the other files have [ ] next to them.

Thanks for any help.

hwttdz

6:10 pm on Jul 7, 2005 (gmt 0)

10+ Year Member



So I don't know how the previous reply did not show up until now, but I believe I have the overrides setup correctly in

<Directory />
AllowOverride All
</Directory>

coopster

6:26 pm on Jul 7, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



So you are past the 403 error now?

hwttdz

6:48 pm on Jul 7, 2005 (gmt 0)

10+ Year Member



Yes I'm past the 403 error, in fact I just found out how to make it display images, but it displays the default image for every file, and it won't reference only one image folder for every directory. By this second part I mean I'd like to have one icons folder in www\icons and have it look there every time but now it's making me have a icons folder in every folder in www and every subfolder?

Right now httpd.conf looks like

<Directory />
Options Indexes
IndexOptions FancyIndexing
IndexOptions FoldersFirst
DefaultIcon ./icons/unknown.gif
AddIconByType (IMG,./icons/image.gif) image/*
AddIconByType (SND,./icons/sound.gif) audio/*
AddIconByType (TXT,./icons/text.gif) text/*
AllowOverride All
Order allow,deny
Deny from all
</Directory>

hwttdz

6:56 pm on Jul 7, 2005 (gmt 0)

10+ Year Member



I'm a step closer I had to take them out of the <directory> tags. Now it's giving the folders the default one.

hwttdz

7:09 pm on Jul 7, 2005 (gmt 0)

10+ Year Member



Think I've got it all settled, thanks for the help.

coopster

7:17 pm on Jul 7, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Excellent. Yeah, you don't need/want <Directory> containers in a per-directory override. Glad you got it sorted. You may want to post your solution for future readers though ;)

hwttdz

7:24 pm on Jul 7, 2005 (gmt 0)

10+ Year Member



I think the significant parts are all here.


<Directory />
Options Indexes
IndexOptions FancyIndexing
IndexOptions FoldersFirst
AllowOverride All
Order allow,deny
Deny from all
</Directory>

AddIconByType (IMG,/icons/image.gif) image/*
AddIconByType (SND,/icons/sound.gif) audio/*
AddIconByType (TXT,/icons/text.gif) text/*
AddIcon /icons/text.gif .php
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^
AddIcon /icons/back.gif ..
DefaultIcon /icons/unknown.gif

Then icons go in webroot\icons
And this text is from httpd.conf