在IIS 7.5中,您可以添加自定义http标头,但是当您这样做时,它们将应用于所有文件类型.我只想要一个特定文件类型(png,jpg,gif)的自定义http标头,没有相同的自定义http标头应用于从Web服务器请求的所有文件类型.
我需要一个通过web.config文件实现这一目标的解决方案,除非有一个与php 5.4 Web应用程序兼容的编码解决方案.
所以,我已经看到了其他答案和其他网站中使用的这个解决方案(http://www.hanselman.com/blog/HowToEnableHTTPStrictTransportSecurityHSTSInIIS7.aspx),但我不明白HSTS标头是如何添加的.我认为它与此有很多关系:
<match serverVariable="RESPONSE_Strict_Transport_Security" pattern=".*" />
Run Code Online (Sandbox Code Playgroud)
有人可以解释"RESPONSE_Strict_Transport_Security"的来源吗?
完整代码:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}"
redirectType="Permanent" />
</rule>
</rules>
<outboundRules>
<rule name="Add Strict-Transport-Security when HTTPS" enabled="true">
<match serverVariable="RESPONSE_Strict_Transport_Security"
pattern=".*" />
<conditions>
<add input="{HTTPS}" pattern="on" ignoreCase="true" />
</conditions>
<action type="Rewrite" value="max-age=31536000" />
</rule>
</outboundRules>
</rewrite>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud) 在IIS 7.5中,您可以添加静态HTTP响应标头,但我想添加一个"Expires"标头,该标头始终指定将来7天的日期.
我正在运行php 5.4,所以我想要一个可以通过编辑web.config文件而不是一些c#代码解决方案来做到这一点的解决方案.
我知道如何使用php添加标题,但这对静态图像文件的http标头(jpg,gif,png等)没有帮助.
标题应如下所示:
到期日:2012年5月31日星期四10:59:25 GMT
如何动态制作它总是显示未来7天的日期和时间?
编辑:
请注意,我在php文件中有我想要的expires头:
http://web-sniffer.net/?url=http%3A%2F%2Fwww.bestds.com
但是,我无法为png文件中的"Expires"键指定提前7天的日期(例如),我将来必须使用静态日期:
http://web-sniffer.net/?url=http%3A%2F%2Fwww.bestds.com%2Fimage%2Ftlogo.png