Forum Discussion
Evaluating data pulled from a data group
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?
data_group
product := product1
uri_search_string := ([string tolower [HTTP::uri]] equals "/xyz" || [string tolower [HTTP::uri]] contains "/abc/123") and not ([string tolower [HTTP::query]] contains "a1=y" || [string tolower [HTTP::query]] contains "a2=y")
iRule
set project [class match -value project equals data_group]
set uri_search_string [class match -value uri_search_string equals data_group]
if { $uri_search_string } {
do redirect and other stuff here}
else {
do other stuff here}
6 Replies
- Arie
Altostratus
Can you supply some sample URLs and actions based on each? That may make your request a bit easier to understand.
- Rich_125959
Nimbostratus
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.
http://domain.com/abc
http://domain.com/xyz/123
The NOT portion of the statement is not working yet. Any ideas?
http://domain.com/abc?x=y
DataGroupsdatagroup_http_path_equals
datagroup_http_path_contains
datagroup_http_query_not_contains
iRuleif { ( [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}
- Arie
Altostratus
What are the values in the class "datagroup_http_query_not_contains"?
- Rich_125959
Nimbostratus
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.
Thanks for your help.
- Rich_125959
Nimbostratus
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.
Thanks for your help.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com