代码之家  ›  专栏  ›  技术社区  ›  Magnus

使用IIS阻止对单个子文件夹的web访问?

  •  0
  • Magnus  · 技术社区  · 5 年前

    logs 网站上的子文件夹。以下 web.config 似乎有用。。。

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

    原木 所有子文件夹中的文件夹( foo/logs , foo/bar/logs 等等)。

    我怎么能只挡住 web.config配置 文件?

    我知道我可以 web.config配置 直接在 原木

    0 回复  |  直到 5 年前
        1
  •  0
  •   Jalpa Panchal    5 年前

    可以使用iis url重写规则来阻止对特定文件夹的请求。

    规则如下:

      <rule name="RequestBlockingRule16" stopProcessing="true">
                    <match url=".*" />
                    <conditions>
                        <add input="{URL}" pattern="^/s2/(.*)" />
                    </conditions>
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden: Access is denied." statusDescription="You do not have permission to view this directory or page using the credentials that you supplied." />
                </rule>
    

    enter image description here

    enter image description here

    文件夹结构:

    enter image description here

    enter image description here