为文件匹配条件添加自定义 http 响应 headers

Add custom http response headers for files matching conditions

我需要向来自我的 IIS 8.5 的每个 http 响应添加自定义 http header,但仅限于特定文件类型(css、js 和 html)。

我试过这个解决方案 Add custom header based on file type,但它似乎已过时,而且我收到有关错误 web.config 文件的错误。

如何在 IIS 8.5 上完成?
任何帮助将不胜感激。

此 link 的解决方案仍然有效 Add custom header based on file type 解决您的问题。

您无法使用它,因为您需要为 IIS 安装 URL 重写模块。

请到https://www.iis.net/downloads/microsoft/url-rewrite下载、安装然后重启IIS。完成此步骤后,有关错误 web.config 文件的错误应该消失了