20-Apr-2021 14:28
I'm trying to craft an irule to do the following: If user hits site-1 and has /europe/[HTTP::uri], redirect him to site-2, remove /europe and add /america, and append trailing URI of the initial request.
when HTTP_REQUEST {
if {[HTTP::host] == www.site-1.com && [HTTP::uri] == "/europe/[HTTP::uri]" } {
HTTP::redirect "www.site-2.com/america/[HTTP::uri] }
}
Solved! Go to Solution.
20-Apr-2021
14:56
- last edited on
04-Jun-2023
20:57
by
JimmyPackets
Hi VFB,
You can use string map for string replacement.
https://devcentral.f5.com/s/articles/irules-101-14-tcl-string-commands-part-2
when HTTP_REQUEST {
if { [HTTP::host] equals "www.site-1.com" && [HTTP::uri] starts_with "/europe/" } {
HTTP::redirect "https://www.site-2.com[string map {/europe/ /america/} [HTTP::uri]]"
return
}
}
20-Apr-2021
14:56
- last edited on
04-Jun-2023
20:57
by
JimmyPackets
Hi VFB,
You can use string map for string replacement.
https://devcentral.f5.com/s/articles/irules-101-14-tcl-string-commands-part-2
when HTTP_REQUEST {
if { [HTTP::host] equals "www.site-1.com" && [HTTP::uri] starts_with "/europe/" } {
HTTP::redirect "https://www.site-2.com[string map {/europe/ /america/} [HTTP::uri]]"
return
}
}