【问题标题】:iis web.config location path exclude files (= paths with extensions)iis web.config 位置路径排除文件(= 带扩展名的路径)
【发布时间】:2019-01-14 19:02:08
【问题描述】:

我想将 customHeaders 添加到我的所有路线中。但仅限于我域中的实际路径,而不是文件。

<location path="???">

标题应添加到:

domain.com
domain.com/dashboard

但不是

domain.com/someimage.jpg

【问题讨论】:

    标签: iis web-config


    【解决方案1】:

    您可以使用 IIS 重写模块来编写自定义出站规则。它已经有 OOTB 条件来检查 URL 是否是文件。类似下面的,this 问题类似:

    <rewrite>
      <outboundRules>
        <rule name="Set custom HTTP response header">
          <match serverVariable="Custom header" pattern=".*" />
          <conditions>
             <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
          </conditions>
          <action type="Rewrite" value="Your value"/>
        </rule>
      </outboundRules>
    </rewrite>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-20
      • 1970-01-01
      • 2015-04-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多