【问题标题】:IIS 10 - web.config - how to enable default document without script accessIIS 10 - web.config - 如何在没有脚本访问的情况下启用默认文档
【发布时间】:2021-01-21 22:27:34
【问题描述】:

我们有一个仅包含静态 html 和图像等的文件夹。不应允许从该文件夹中执行任何脚本。但是我们仍然希望能够使用 html 默认文档。

正确的配置方法是什么?

这是 web.config 文件...

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers accessPolicy="Read"/>
    <defaultDocument enabled="true">
      <files>
        <clear />
        <add value="default.html" />
        <add value="default.htm" />
      </files>
    </defaultDocument>
  </system.webServer>
</configuration>

如果我尝试访问 http://mysite/mystaticfolder/ 会失败并出现错误...

HTTP 错误 403.1 - 禁止

但是 URL http://mysite/mystaticfolder/default.html 工作正常。

肯定不需要允许动态脚本,只是为了能够提供静态 html 默认文档?

【问题讨论】:

    标签: web-config iis-10


    【解决方案1】:

    如果它对任何人有帮助,我已经能够通过以下方式解决它......

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <handlers accessPolicy="Read">
          <clear/>
          <add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule" resourceType="Either" requireAccess="Read" />
        </handlers>
        <defaultDocument enabled="true">
          <files>
            <clear />
            <add value="default.html" />
            <add value="default.htm" />
          </files>
        </defaultDocument>
      </system.webServer>
    </configuration>
    

    我不完全确定为什么这在默认情况下不起作用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-15
      • 1970-01-01
      • 1970-01-01
      • 2018-12-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多