0

I am trying to use mod_headers to change Location headers that are being sent via the mod_alias using the Redirect directive but none of them are being re-written. I have the following in my http.conf;

Header edit Location //example.com //example.com.dev

And within an .htaccess file I have:

Redirect temp /foo http://example.com/

But the headers are never changed. I can confirm it is loading the module and reading the directives by adding the following just beneath the other directive:

Header set FOOBAR bazbax

And I can see the new header appear.

What do I to do to get this working correctly?

nathanjosiah
  • 165
  • 3
  • 13
  • This could do with the order or processing. But what is the end goal? Using mod rewrite may be preferred in this case. – jeffatrackaid Oct 28 '13 at 20:40
  • We are currently in the process of migrating to a better development workflow and configuring our local machines to be development machines using the current code. I can't change the URL's in the htaccess because it needs to work on the dev and production servers. I have also been told there can be no dev environment checking on the production server. If I could just filter the Location headers that would be the last of my changes without adding any code. – nathanjosiah Oct 28 '13 at 21:36

1 Answers1

1

In the mod_headers documentation, the Header Directive states the following:

The optional condition argument determines which internal table of responses headers this directive will operate against. Other components of the server may have stored their response headers in either the table that corresponds to onsuccess or the table that corresponds to always. "Always" in this context refers to whether headers you add will be sent during both a successful and unsucessful response, but if your action is a function of an existing header, you will have to read on for further complications.

The default value of onsuccess may need to be changed to always under the circumstances similar to those listed below. Note also that repeating this directive with both conditions makes sense in some scenarios because always is not a superset of onsuccess with respect to existing headers:

  • You're adding a header to a non-success (non-2xx) response, such as a redirect, in which case only the table corresponding to always is used in the ultimate response.

...

This is most likely the issue you're experiencing, since you're issuing a 3xx response through mod_alias.

justbeez
  • 136
  • 2