Forum Discussion
Cookie and URI irule not working?
We have some ltms with 10.2 that will need to match on a cookie and uri irule logic and doesn't seem to be working properly.
when HTTP_REQUEST { if { ([class match [HTTP::cookie "UserInfo"] contains companyX]) and ( not [string tolower [HTTP::uri]] contains "/serviceb/")} { pool SERVER1 } }
I noticed that the cookie logic works fine by itself, but when I add the "and" logic it doesn't work. I'm wondering if my configuration is correct?
6 Replies
- Kevin_Davies_40
Nacreous
Probably need to move brackets around like below.
when HTTP_REQUEST { if { ([class match [HTTP::cookie "UserInfo"] contains companyX]) and \ not ([string tolower [HTTP::uri]] contains "/serviceb/")} { pool SERVER1 } }Just a tip, when posting iRules. Select your code and then press Tab. It will format it nicely for you ๐
- JCMATTOS_41723
Nimbostratus
Kevin,
Thx for you response. Is the \ after the "and" a typo?
when HTTP_REQUEST { if { ([class match [HTTP::cookie "UserInfo"] contains companyX]) and \ not ([string tolower [HTTP::uri]] contains "/serviceb/")} { pool SERVER1 } }
- Cory_50405
Noctilucent
Take the \ out of the iRule. I think Kevin meant that as an indicator that the statement was continued on the next line.
- nitass
Employee
Is the \ after the "and" a typo?
Another common use of backslash substitution is for line continuation: Continuing long commands on multiple lines. When a line ends with a backslash, the interpreter converts it and the newline following it and all whitespace at the beginning of the next line into a single space character, then evaluates the concatenated line as a single command:iRules Optimization 101 - 04 - Delimiters: Braces, Brackets, Quotes and more by Deb Allen
https://devcentral.f5.com/articles/irules-optimization-101-04-delimiters-braces-brackets-quotes-and-more.U5iQMihhfIU - Kevin_Davies_40
Nacreous
The \ is a continuation character. If you put the following line back on the same line you don't need it.
iRules/TCL is a bit quirky though. Sometimes it likes it and sometimes.... if its throwing errors then remove it.
- Kevin_Davies_40
Nacreous
If any of the below posts have provided a solution to your issue, please indicate so by clicking the tick to the left of them. This gives feedback and recognition to the volunteers who responded to your issue :-)
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