deadprogrammer deadprogrammer - 1 year ago 119
Apache Configuration Question

How to add additional headers to 302 redirects in Apache?

I have a redirect in Apache config like

Redirect temp /foo.xml

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.

Normally this is done like this:

ExpiresActive On
ExpiresDefault "access plus 10 minutes"

but this only seems to not work for 302 redirects. Any suggestions?

Answer Source

Check out the mod_headers module for Apache.

Perhaps something like:

<Location /foo.xml>
   Redirect temp /foo.xml
   Header always set ExpiresActive On
   Header always set ExpiresDefault "access plus 10 minutes"

I have edited this answer (since it was accepted), adding the always keyword, to reflect what Fix correctly pointed out below.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download