1

I have a folder containing a web page index.html that redirects to another page. When I type in the browser the URL of that directory without specifying a file name, I expect it to open the index.html which redirects to the intended page. But when I open a directory in any of my browsers (Chrome, Firefox), the directory structure/tree is shown instead:

Index of C:\Users\User1\Documents\
[parent directory]

Why doesn't the browser open the index.html file? I am using Windows 7.

3
  • 1
    You need to provide more information. This is not a browser issue. This is a configuration issue, with what I presume is IIS. First disable directory listing, and then make sure the default document is set. Dec 21, 2017 at 2:31
  • How do I disable directory listing?
    – JAT86
    Dec 21, 2017 at 2:34
  • technet.microsoft.com/en-us/library/cc731109(v=ws.10).aspx - its similar in iis 8 probably. It's been a while since I played with this stuff. Dec 21, 2017 at 3:00

2 Answers 2

6

Because you are accessing it with a file:// reference and it is not being served by a webserver.

The fact that you can go to a directory and get a default file is part of the webserver config - Apache has the DirectoryIndex directive which often specifies multiple files (index.htm, index.html, index.php, etc), from what I recall IIS uses "Default.htm"

1

Why doesn't the browser open the index.html file?

As pointed out in the comments, the two most likely causes are:

  • Having directory listings enabled (which show individual files in a directory).

  • Having your default page association(s) (often referred to as default documents) configured incorrectly (e.g. you are using index.html when the server is only configured to recognize index.htm files as valid default web pages).

IIS

If you are using IIS, there should be an option called Directory Browsing in the central IIS Manager window (the Features View pane). Note that you must select a "level" (a server or site instance in the left-hand window) before this option appears. Once selected for a given level, you can toggle Directory Browsing in the right-hand window (the Actions pane) via Enable/Disable. This can be done server-wide, for individual sites or even specific directories.

To configure default document settings in IIS, right-click the site or folder then click Properties. Select the Documents tab and click the "Enable Default Document" check box if it isn't already selected. You can add a new default document by clicking Add. In the Default Document Name box, type the name of the default document (e.g. index.html) and click OK when finished. Note that it is possible to have more than one default document (e.g. index.htm and index.html). You can change the order of preference (what IIS looks for first) if you wish.

Apache

In httpd.conf (or wherever appropriate), you will want to remove the Indexes parameter for any Options directive to disable directory listings. To specify your default document(s), look for the applicable DirectoryIndex directive and specify the appropriate name(s) in a list e.g.

DirectoryIndex index.htm index.html index.php home.php foo.bar

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .