Click here to get back home

How to stop directory listing a folder

 HomeNewsGroups | Search

get this group's latest topics as an RSS feed  comp.infosystems.www.authoring.html - discuss HTML authoring here

please rate
this thread
If you were  Registered and logged in, you could reply and use other advanced thread options
Posted by gil on January 22, 2006, 2:51 am


Is it possible to prevent a browser from listing the entire contents of
a folder?

The site, is hosted on my ISP with the following layout-

site/  "user name from ISP"
pagefile        (dir)
index.html

site/pagefile/
images  (dir)
drawings        (dir) plus several other dir's
home.html        plus 36 other .html files
style.css

site/pagefile/images/
20 files all .jpg or .gif

site/pagefile/drawings/
60 files all .jpg

etc., etc.

****

If I edit my browser to http address "site" (with or without trailing
"/") the 'index.html' file opens, while "site/pagefile(/)" will always
open just the 'home.html' file, NOT any of the other .html files in the
same directory. This seems to be good.

However, when I try "site/pagefile/images" or ".../drawings", I get a
generic directory listing page, showing all of the files and directories
within the named address, including a link to the parent directory. This
is not good. If I hit the link to 'parent directory' then the
'home.html' file will open.

I have tried putting a small .html file in each image folder but the
tree still displays. I have not tried putting a folder within the
folder, but suspect that it would also show in the tree listing.

This occurs in IE 6.0, Moz 1.7 and Opera 8.5.

Discussions on robots.txt are aimed at search engine robot crawlers, not
the typical users browser.

How can I prevent the image folders from showing a generic directory
listing, or can I get them to instead display a "list access denied"
type of message?

Gil




 

Posted by Els on January 22, 2006, 3:04 am


gil wrote:



[snip]



If you name that file index.html, you'll see the same behaviour as in
the parent directories.



Yes, it will.
 


It's on the server that this happens, not in the browser.
 


Yup.
 


Either put an index.html file in every directory, or deny directory
listings on the server. If you are on a Linux server, this is done in
the .htaccess file. If you have CPanel, you can even take care of it
without having to touch the .htaccess yourself.

--
Els                     http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
                             - Renato Russo -

Posted by gil on January 22, 2006, 3:51 am




At approximately 2006/01/22 04:04, Els typed these characters:



Thanks Els,
I took your advice and placed a "listing denied" type message into a
document called 'index.html'. After placing a copy in each directory,
the site will no longer list the directory tree.

Gil

Posted by Stan Brown on January 22, 2006, 10:52 am


Sun, 22 Jan 2006 08:51:22 GMT from gil


I think you may have misinterpreted that advice. :-) Actually you've
now got the worst of both worlds: your server has the overhead of
serving up a useless page, and your visitors get a nasty message. In
addition, since you've got a real file there, search engines will
index it, which is almost certainly not what you want.

What you want to do is either (a) put a real index.html file, with
actual content, in the directory, or (b) set the server configuration
not to list files in a directory when it contains no default-type
page.

Els told you how to do (b). I would add only that not Linux but any
Apache server will respond to a .htaccess file(*). See


(*) unless your ISP has disabled that capability, in which as you
should insist politely but firmly that it be turned back on.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
                                  http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator:      http://validator.w3.org/
CSS 2.1 spec:   http://www.w3.org/TR/CSS21/
validator:      http://jigsaw.w3.org/css-validator/
Why We Won't Help You:
    http://diveintomark.org/archives/2003/05/05/why_we_wont_help_you

Posted by gil on January 22, 2006, 12:25 pm



At approximately 2006/01/22 11:52, Stan Brown typed these characters:


The index.html file I have added to each directory is a small, politely
worded message telling the user that they do not have permission to list
the files, and includes a link back to my homepage.

My ISP provides its customers with free web space for personal use, but
offers no customer support beyond how to access the space. I have no
information on checking logs, or how, or where the .htaccess file is to
be formatted or located.

With the above limitations, I think the index.html page option is the
most reasonable.


Subject Author Date
How to stop directory listing a folder gil 01-22-2006
If you were  Registered and logged in, you could reply and use other advanced thread options
  • Subject
  • Date

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Driving a better car - Fuelzilla.com

Cabling site for homeowners and pros alike - Cabling-Design.com

1-Script XML SitemapXML Sitemap
Privacy Policy