Walter_WorkAcct
Apr 24, 2021Altostratus
iRule with multiple 301 redirects only redirecting main URI
I am new to the F5 and working on an irule to 301 permanently redirect traffic from links to our old site to new locations on the new site. The issue is that only the default portion of the code is working. It isn't picking up on the switch statements to redirect to other areas. Can anyone point me in the right direction on how to troubleshoot?
Example code:
when HTTP_REQUEST {
if { [HTTP::uri] contains "oldsite.ournewsite.net" } {
switch -glob [HTTP::uri] {
"*/foo" { HTTP::respond 301 "Location" "https://ournewsite.net/oldsitestuff/foo"}
"*/bar" { HTTP::respond 301 "Location" "https://ournewsite.net/oldsitestuff/bar"}
default { HTTP::respond 301 "Location" "https://ournewsite.net/oldsitestuff"}
}
}
}