2

I am using webspace hosted on IIS 7.5 (according to phpinfo() ). Currently, I am enabling directory listings for a directory and all its subdirectories by placing a web.config like

<location path=".">
    <system.webServer>
      <directoryBrowse enabled="false" />
    </system.webServer>
</location>

in it. Is there a way to disable the directory listing in the directory itself but enable it for all its subdirectories without placing a web.config in each subdirectory or listing all subdirectories here?

2

If this works in a similar way to Apache, then you could simply create an index.php file (or whatever your directory index file is) in the directory that you don't want to see a directory listing.

3

Yes if you allowOverride and then add a new web.config file in the folder you want to disable.

So in your parent folder web.config should look like this.

<configuration>
   <location path="." allowOverride="True">
      <system.webServer>
         <directoryBrowse enabled="True" />
      </system.webServer>
   </location>
<configuration>

In the folders you want to disable directory browse the web.config should look like this.

<configuration>
   <location path=".">
      <system.webServer>
         <directoryBrowse enabled="False" />
      </system.webServer>
   </location>
<configuration>

For more info check this article.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.