Forum Discussion
Mar 23, 2015
Hi Steve,
thefindstr
function will help:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] equals "this.example.com" } {
if { [string tolower [HTTP::path]] starts_with "/documents/" } {
HTTP::redirect "http://serverA:8080[findstr [string tolower [HTTP::uri]] "/documents" [string length "/documents"]]"
} elseif { [string tolower [HTTP::path]] starts_with "/logs/" } {
HTTP::redirect "http://serverB[findstr [string tolower [HTTP::uri]] "/logs" [string length "/logs"]]"
} elseif { [string tolower [HTTP::uri]] starts_with "/reports/" } {
HTTP::redirect "http://serverB[findstr [string tolower [HTTP::uri]] "/reports" [string length "/reports"]]"
} else {
HTTP::redirect "http://this.example.com[HTTP::uri]"
}
}
}
There are smarter solutions based on the
switch
command (jump table).
Please note, that there is no action defined, if the initial condition (host name) does not match.
Thanks, Stephan