14-Aug-2020 15:47
I've got an irule which doing 301 redirects. When a particular uri comes in, it checks the locale and matches it against a data-group with old locale in the uri being mapped to a new local.
For example "en_US" would map to "en-us" as the new value. It works fine for the most part, but if the locale that comes doesn't match a particular value in the data-group, it leaves the locale field blank in the 301 redirect. If the locale field in the uri contained something like /locale=en_ZZ, the redirect would just blank in the redirect.
Instead, we want it to redirect to a default page, and I'm not quite sure how to do that. First in the class match statement it would need to check if a matching value existed, but I'm not sure how to do that, and the class page on devcentral is a little confusing.
Solved! Go to Solution.
17-Aug-2020
08:42
- last edited on
04-Jun-2023
21:19
by
JimmyPackets
Hello atoth.
Make the most of the command 'else':
when HTTP_REQUEST {
if { [class match [HTTP::uri] equals "location_dg" ] } {
## DO YOUR STUFF
} else {
## DO YOUR STUFF IN CASE OF NOT MATCHING
}
}
Regards,
Dario.
17-Aug-2020
08:42
- last edited on
04-Jun-2023
21:19
by
JimmyPackets
Hello atoth.
Make the most of the command 'else':
when HTTP_REQUEST {
if { [class match [HTTP::uri] equals "location_dg" ] } {
## DO YOUR STUFF
} else {
## DO YOUR STUFF IN CASE OF NOT MATCHING
}
}
Regards,
Dario.
18-Aug-2020 08:37
This worked. Thanks!
18-Aug-2020 10:13
Great! Don't forget to tag the answer as 'the best' 😉