I am building an iRule that will redirect specific traffic. I have several different URL paths (uri_search_string) that I need to set this up for and would like to pull that from a data group along with the product specific information needed in the iRule. I get an error stating that a boolean is expected. I want it to execute or evaluate the code that is pulled from the data group. Is that possible?
The problem is that you are doing a match, not retrieving the value from the datagroup. You need to use class element -value or something like that. Reference here
I stepped back and went at this a little different way. I created 3 datagroups and constructed my if statement to evaluate the contents of the datagroups. Now if the following paths are hit, it is properly redirected to the new URL.
if { ( [class match [string tolower [HTTP::path]] equals ${datagroup_http_path_equals}] || [class match [string tolower [HTTP::path]] contains ${datagroup_http_path_contains}] ) and not ( [class match [string tolower [HTTP::query]] contains ${datagroup_http_query_not_contains}] ) } {Redirect to new url}
I found my issue. The names of the datagroups had a hyphen in it (those shown above were variables set elsewhere in my script). Changing the hyphen in the datagroup names to underscores, resolved my issue.
This works: if { ([class match [string tolower [HTTP::path]] equals HTTPpath_equals ] || [class match [string tolower [HTTP::path]] contains HTTPpath_contains ]) and not ([class match [string tolower [URI::query [HTTP::uri]]] contains HTTPpath_not_contain ]) } {
where the datagroup names are: HTTPpath_equals; HTTPpath_contains; HTTPpath_not_contain
It was interesting that it only affected the ‘and not’ section but…it works now.
I found my issue. The names of the datagroups had a hyphen in it (those shown above were variables set elsewhere in my script). Changing the hyphen in the datagroup names to underscores, resolved my issue.
This works: if { ([class match [string tolower [HTTP::path]] equals HTTPpath_equals ] || [class match [string tolower [HTTP::path]] contains HTTPpath_contains ]) and not ([class match [string tolower [URI::query [HTTP::uri]]] contains HTTPpath_not_contain ]) } {
where the datagroup names are: HTTPpath_equals; HTTPpath_contains; HTTPpath_not_contain
It was interesting that it only affected the ‘and not’ section but…it works now.