【问题标题】:IIS - Deny public access to all files in specified directoryIIS - 拒绝公共访问指定目录中的所有文件
【发布时间】:2016-03-08 00:23:32
【问题描述】:

我需要将 .htaccess 文件转换为 web.config 以在 IIS 7.5 上使用:

IndexIgnore */*
<Files *.php>
    Order Deny,Allow
    Deny from all
</Files>

这旨在通过将文件定位在 /core/.htaccess 来防止公共访问 /core 目录中的任何文件。

应用程序仍然需要访问 /core 目录中的 php 文件和其他资产。

我试过hiddenSegments

<security>
    <requestFiltering>
        <hiddenSegments>
            <add segment="core"/>
        </hiddenSegments>
    </requestFiltering>
</security>

denyUrlSequences

<security>
    <requestFiltering>
        <denyUrlSequences>
            <add sequence="/core/" />
        </denyUrlSequences>
    </requestFiltering>
</security>

但是,这些会阻止管理面板运行,因为以下请求被阻止:

http://www.domain.com/admin/assets/core/admin.js

因为 URL 包含被阻止的序列 core

谁能建议如何在允许管理面板运行的同时阻止对 /core 目录中资源的公开访问?

【问题讨论】:

    标签: .htaccess iis-7 web-config


    【解决方案1】:

    我通过将以下 web.config 放置在应拒绝 URL 访问的目录中来实施解决方案:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <security>
          <requestFiltering>
            <!-- prevent url access to this and sub directories -->
            <denyUrlSequences>
              <add sequence="/" />
            </denyUrlSequences>
          </requestFiltering>
        </security>
      </system.webServer>
    </configuration>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-26
      • 2015-07-30
      • 2014-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多