Reply
Why use index files in every directory?
Old 03-14-2008, 02:49 AM Why use index files in every directory?
EditFast's Avatar
Experienced Talker

Posts: 42
I use a program (Guardian) to send me notifications when an error occurs on my site (404, 403 etc.) These notices contain the URL causing the error and the referring URL. Lately I have been getting numerous notifications with URLs to directories without index files (On a side note, these URLs also contain within them, urls to other sites. I assume this is some spammer technique and I am not too concerned about this in this post but if someone can shed some light on how/why they (the spammers) do this I would appreciate it.)

My purpose in posting here is to find out about the use of index files in directories. I have read that this is a good idea, but I have yet to hear why except that in case someone navigates to the URL of the directory rather than the actual page URL, then they will not get a 403 error message, but this seems like a rather weak reason to me. Is there another reason? SEO reason? Technical reason?

If I find good reason to do this, is it enough to just put a blank index file in each directory? If so why? What purpose does it serve (aside from thwarting the spammers doing what I described above.) Thanks in advance for your help.
EditFast is offline
Reply With Quote
View Public Profile Visit EditFast's homepage!
 
When You Register, These Ads Go Away!
Old 03-14-2008, 04:25 AM Re: Why use index files in every directory?
chrishirst's Avatar
Super Moderator

Posts: 16,452
Location: Blackpool. UK
It's not so much spammers that it stops, but it can prevent "crackers" from "seeing" what files are in the folder. So if the "hunting" bot can't "see" them it won't report a potential target for an attack.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System | Bits & Bobs
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-14-2008, 06:15 AM Re: Why use index files in every directory?
EditFast's Avatar
Experienced Talker

Posts: 42
Quote:
Originally Posted by chrishirst View Post
It's not so much spammers that it stops, but it can prevent "crackers" from "seeing" what files are in the folder. So if the "hunting" bot can't "see" them it won't report a potential target for an attack.
They can't see what's there if the server is set to respond with a 403 error page, which is what I have done as I indicated above.
EditFast is offline
Reply With Quote
View Public Profile Visit EditFast's homepage!
 
Old 03-14-2008, 07:23 AM Re: Why use index files in every directory?
Skilled Talker

Posts: 59
Name: Dan
From a security standpoint best practice states that you should include an index for the reason chris outlines above. It's a belt and braces approach really, if something happens on your webserver and it suddenly allows directory listings as a result of mis-configuration then index files will add an extra layer to prevent directory listings.
Monkey Do is offline
Reply With Quote
View Public Profile
 
Old 03-14-2008, 08:20 AM Re: Why use index files in every directory?
EditFast's Avatar
Experienced Talker

Posts: 42
Quote:
Originally Posted by Monkey Do View Post
From a security standpoint best practice states that you should include an index for the reason chris outlines above. It's a belt and braces approach really, if something happens on your webserver and it suddenly allows directory listings as a result of mis-configuration then index files will add an extra layer to prevent directory listings.
That's a clear and good reason. Now I am convinced. So, just a blank index.htm file is all I need?
EditFast is offline
Reply With Quote
View Public Profile Visit EditFast's homepage!
 
Old 03-15-2008, 08:11 PM Re: Why use index files in every directory?
chrishirst's Avatar
Super Moderator

Posts: 16,452
Location: Blackpool. UK
Yep. ..
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System | Bits & Bobs
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-15-2008, 10:37 PM Re: Why use index files in every directory?
tripy's Avatar
Fetchez la vache!

Posts: 2,251
Name: Thierry
Location: In the void
Or, if apache, you could deactivate the directory listing at all.
It would prevent it without needing to put a blank file everywhere.
http://httpd.apache.org/docs/2.0/mod/core.html#options

Simply add a section like this:
Code:
<directory />
  options -indexes
</directory>
in a .htaccess in the root directory would disable server generation of a list of files in any directory. A 401 - forbidden will be returned.

Warning: the default value of options, if not specified, is "all", so by adding just -indexes, you deactivate all the other.
You must add them (with a +name_of_option) to enabled them back.
I would usually use this:
Code:
options -indexes +ExecCGI +FollowSymLinks +Includes
__________________
Listen to the ducky: "This is awesome!!!"

tripy is online now
Reply With Quote
View Public Profile
 
Old 03-16-2008, 11:40 AM Re: Why use index files in every directory?
QiSoftware's Avatar
Skilled Talker

Latest Blog Post:
A Fresh Start.
Posts: 65
Location: U.S.
The reason to have an index.html file is to prevent directory contents from being provided to surfers when they request the html file specifically. The problem is that in most cases, putting a blank index.html file in the directory overrides the index.php call. This is not good if it is a WordPress or forum directory.

To override this use something like this in the directorys .htaccess file:

DirectoryIndex index.php index.html index.htm index.cgi
Options -Indexes

This makes the index.php file the default and insures no one can see the contents of your directory. Setting indexes off-- does not always fix the problem.

Q...
QiSoftware is offline
Reply With Quote
View Public Profile Visit QiSoftware's homepage!
 
Reply     « Reply to Why use index files in every directory?
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.15105 seconds with 12 queries