Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to conditionally modify Apache response header 'Location'

I need to be able to test the URL string in a Location response header for a certain pattern and if it matches replace it with another.

e.g. if response is Location: http://wrongserver.com I need to change it to Location: http://rightserver.com

Seems mod_setenvif only operates on request headers so I haven't been able to combine this with a "Header set" directive to achieve what I want.

Content is not being proxied so using mod_proxy directives doesn't seem to be an option.

Thanks, Bernie

like image 791
user3913979 Avatar asked Aug 06 '14 10:08

user3913979


1 Answers

You should be able to do this with mod_headers

Header edit Location ^http://wrongserver.com$ http://rightserver.com

More info here: https://httpd.apache.org/docs/current/mod/mod_headers.html#header

like image 124
arco444 Avatar answered Sep 20 '22 22:09

arco444