3

我在 web.config 中添加了以下内容,因此用户无法下载我的插件:

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

现在我遇到的问题不仅domain.com/Plugins/MyPlugin.dll是被阻止,而且domain.com/Scripts/ckeditor/plugins/ckplugin.js.

有没有办法将 hiddenSegment 配置为仅影响根目录?

4

2 回答 2

2

我通过我的插件文件夹中的 web.config 解决了这个问题,我在其中阻止 *.dll 文件被下载:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <add name="Plugins*.dll_*" path="*.dll" verb="*" type="System.Web.HttpForbiddenHandler" />
            <add name="Plugins*.pdb_*" path="*.pdb" verb="*" type="System.Web.HttpForbiddenHandler" />
        </handlers>
    </system.webServer>
</configuration>
于 2014-01-08T08:40:46.667 回答
2

我在 Christoph 的回答之上做了一些额外的修改以适应我的用例,但我将把它留在这里以供将来参考。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!-- Make sure this directory cannot be served. -->
  <location path="Plugins"> <!-- Change this to your path -->
    <system.webServer>
      <handlers>
        <add name="DisallowServe" path="*.*" verb="*" type="System.Web.HttpNotFoundHandler" /> <!-- Return 404 instead of 403 -->
      </handlers>
    </system.webServer>
  </location>
</configuration>
于 2020-11-23T07:44:13.250 回答