我想将自定义标头添加到我的所有路由中。但仅限于我的域中的实际路径,而不是文件。
<location path="???">
标头应添加到:
domain.com
domain.com/dashboard
但不是
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>