问题描述
我在Apache配置中有一个重定向,例如
I have a redirect in Apache config like
重定向临时/foo.xml
Redirect temp /foo.xml http://www.baz.com/foo.xml
我正在尝试添加Expire和m-缓存CDN到此302的标头。这在php中是微不足道的,但是我需要在Apache配置文件中做到这一点。
I am trying to add an Expire and m-cache headers for a CDN to this 302. This would be trivial in php, but I need to do this in Apache config files.
通常这样做是这样的:
ExpiresActive于
ExpiresDefault默认为访问加上10分钟
ExpiresActive On ExpiresDefault "access plus 10 minutes"
但这似乎仅对302重定向无效。有建议吗?
but this only seems to not work for 302 redirects. Any suggestions?
推荐答案
查看Apache的mod_headers模块。
Check out the mod_headers module for Apache.
可能类似于:
<Location /foo.xml>
Redirect temp /foo.xml http://www.baz.com/foo.xml
Header always set ExpiresActive On
Header always set ExpiresDefault "access plus 10 minutes"
</Location>
我已经编辑了此答案(自接受以来),并添加了始终 >关键字,以反映Fix在下面正确指出的内容。
I have edited this answer (since it was accepted), adding the always keyword, to reflect what Fix correctly pointed out below.
这篇关于如何在Apache的302重定向中添加其他标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!