OK, let's add some debugging logs to see what's happening:
when HTTP_REQUEST {
log local0. "Request from [IP::client_addr] URI: [HTTP::uri]"
if { [string tolower [HTTP::uri] ] starts_with "/app/" } {
node 192.168.10.20 80
HTTP::uri [string map -nocase {"/app/" "/"} [HTTP::uri]]
log local0. "Request from [IP::client_addr] URI: [HTTP::uri] matched /app"
}
}
when HTTP_RESPONSE {
log local0. "Response to [IP::client_addr] Status: [HTTP::status]"
if {[HTTP::is_redirect]} {
log local0. "Response to [IP::client_addr] original Location: [HTTP::header Location]"
HTTP::header replace Location [string map -nocase "https://example.com/test https://example.com/app/test" [HTTP::header Location]]
log local0. "Response to [IP::client_addr] modified Location: [HTTP::header Location]"
}
}