Forum Discussion
AlexDeMarco
Nimbostratus
Sep 25, 2012How to narrrow the match
Here is a small snippet of my code:
([string tolower [HTTP::uri]] starts_with "/ca") ||
We have an application where the context is just /ca so this is working fine for it. However, we have a directory called /capital which this irule is also firing on. How can narraw the match so it is only /ca ?
thanks!
- Alex
- Mohamed_Lrhazi
Altocumulus
There should be a "string fucntion" called "equals", instead of using "starts_with" - Mohamed_Lrhazi
Altocumulus
Oh, it not a string function, but an "operator" : https://devcentral.f5.com/wiki/iRules.Operators.ashx - What_Lies_Bene1
Cirrostratus
equals probably won't be useful as the /ca is probably only the start of a full URI? If that's the case you could match on /capital prior to the code you've posted and either terminate rule processing there or 'jump over' the /ca check and processing. - What_Lies_Bene1
Cirrostratus
Or perhaps you could match on /ca/? - AlexDeMarco
Nimbostratus
I probably should use a regex to only match on exactly the phrases I want. - Michael_Yates
Nimbostratus
Changing your matching order would probably be your best bet. Regular expressions can get expensive in processing times and efficiency loss.when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/capitals*" { pool firstpool; return } "/capital*" { pool secondpool; return } "/caps*" { pool thirdpool; return } "/california*" { pool fourthpool; return } "/ca*" { pool fifthpool } default { pool defaultpool } } }
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects