cancel
Showing results for 
Search instead for 
Did you mean: 

Checking if a value exists in a data-group?

atoth
Cirrus
Cirrus

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.

1 ACCEPTED SOLUTION

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.

Regards,
Dario.

View solution in original post

3 REPLIES 3

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.

Regards,
Dario.

atoth
Cirrus
Cirrus

This worked. Thanks!

Great! Don't forget to tag the answer as 'the best' 😉

Regards,
Dario.