[ACCEPTED]-How to make IIS7 stop serving a folder?-iis-7

Accepted answer
Score: 31

The proper way to do that is using this:

<configuration>
   <system.webServer>
       <security>
          <requestFiltering>
               <hiddenSegments>
                   <add segment="My_Directory" />
               </hiddenSegments>
           </requestFiltering>
       </security>
   </system.webServer>
</configuration>

This 8 allows you to still access files located 7 there from the IUSR account, but prevents actual 6 requests for files there from being filled 5 directly.

Note that this will block files 4 in that directory, and any subdirectories, no 3 matter where that directory occurs - even 2 if it, itself, is a sub-directory of something 1 else.

Score: 3

As the link-only answer points out, hiddenSegments is 9 the right tool for the job. Go to IIS then 8 the site and in Features find Request Filtering (must be installed at 7 Server Manager) now add directory name that you want to 6 prevent access to, or any segment of the 5 URL really. This approach does require that 4 a unique url or directory name be used in 3 the site, otherwise any other occurrence 2 of the segment at any level in the url, will 1 cause that request to be blocked:

http://www.iis.net/configreference/system.webserver/security/requestfiltering/hiddensegments

Score: 1

Remove IIS_IUSR permissions from that folder.

I 2 think its generically under the "Internet 1 Guest Account"

More Related questions