iis web.config位置路径排除文件(=带扩展名的路径)

iis web.config位置路径排除文件(=带扩展名的路径),iis,web-config,Iis,Web Config,我想将CustomHeader添加到我的所有路线。但仅指向域中的实际路径,而不是文件 <location path="???"> 但不是 domain.com/someimage.jpg 您可以使用IIS重写模块编写自定义出站规则。它已经具有OOTB条件来检查URL是否为文件。问题类似于以下内容: <rewrite> <outboundRules> <rule name="Set custom HTTP response header"&

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

<location path="???">
但不是

domain.com/someimage.jpg

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

<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>

<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>