After brainstorming with some coworkers, we came up with this.
when HTTP_REQUEST {
set uri_redirect 0
switch -glob [HTTP::path] {
"/blah/blah/blah*" {
set uri_redirect 1
HTTP::header replace "Host" "external.domain.com"
HTTP::redirect "https:// [getfield [HTTP::host] ":" 1][string map {/blah/blah/blah /a/b/c } [HTTP::path]]"
pool redirect-pool
snat automap
} "/a/b/c*" {
set uri_redirect 0
HTTP::header replace "Host" "external.domain.com"
pool redirect-pool
snat automap
} default { pool default-pool }
}
}
when HTTP_RESPONSE {
if { [HTTP::is_redirect] } {
if { $uri_redirect == 1 } { HTTP::header replace "Host" "internal.domain.com"
HTTP::redirect "https:// [getfield [HTTP::host] ":" 1 ][string map { /a/b/c /blah/blah/blah } [HTTP::path]]"
} else {
HTTP::header replace "Host" "internal.domain.com"
}
}
}
However, after trying it out in the editor and fixing a bunch of errors, I still get
line 21: [command is not valid in current event context (HTTP_RESPONSE)] [HTTP::host]
line 21: [command is not valid in current event context (HTTP_RESPONSE)] [HTTP::path]
Anyone know of a way of rewriting the URI without resorting to using [HTTP::host] or [HTTP::path] ?