Appendix C: Scripts : Examples : Rewrite the HTTP response Location header
 
Rewrite the HTTP response Location header
You can use the content rewriting feature to rewrite the HTTP response Location header. If you are more comfortable using Lua string substitution, you can write a script to get the results you want. The following example rewrites the HTTP response Location header.
 
-- Rewrite the HTTP body in the response
when RULE_INIT {
debug("rewrite the HTTP response replacing myold.hostname.com with mynew.hostname.com \n")
}
 
when HTTP_RESPONSE{
location = HTTP:header_get_value("Location")
if location:lower():find("myold.hostname.com") then
debug("found myold.hostname.com in Location %s \n", location)
HTTP:header_replace("Location", "mynew.hostname.com")
end
}