Forum Discussion
AppWorld DC Booth Kiosk Generator
iRule Explanation - from the iRules Toolbox
Source: path_parsing_with_glob_style_matching.txt
# Create an F5 BIG-IP iRule that routes HTTP requests to different pools based on the first two characters of the URL path. The rule should use case-insensitive matching and handle paths starting with /a, /b, and /c, followed by specific ranges of letters. Include a default case for paths that don't match any specified patterns. The rule should have default priority and use efficient matching techniques.
when HTTP_REQUEST priority 500 {
# Parse the first then second character in the path
# Convert the path to lowercase for case-insensitive matching
switch -glob -- [string tolower [HTTP::path]] {
# If path starts with /a followed by a-l, route to this pool
"/a[a-l]*" {
pool reward-uat5.123.com_AA2AL
}
# If path starts with /a followed by m-z, or /b followed by a-l, route to this pool
"/a[m-z]*" -
"/b[a-l]*" {
pool reward-uat5.123.com_AM2BL
}
# If path starts with /b followed by m-z, or /c followed by a-d, route to this pool
"/b[m-z]*" -
"/c[a-d]*" {
pool reward-uat5.123.com_BM2CD
}
# Default case: if none of the above patterns match (including just a forward slash)
default {
# Route to the first pool as a fallback
pool reward-uat5.123.com_AA2AL
}
}
}Explanation (generated by F5 Distributed Cloud AI Assistant):
Objective
• This iRule routes incoming HTTP requests to different server pools based on the first two characters of the URL path.
• It performs case-insensitive matching by converting the path to lowercase.
• Paths beginning with /a (subdivided into a-l and m-z), /b (a-l and m-z), and /c (a-d) each map to a specific pool.
• Any path not matching these patterns (including /) falls back to the first pool.
Execution Flow
The HTTP_REQUEST event fires with priority 500.
[HTTP::path] is converted to lowercase using string tolower.
switch -glob -- evaluates the lowercase path against patterns, in order:
• Pattern /a[a-l]* → pool reward-uat5.123.com_AA2AL
• Patterns /a[m-z]* OR /b[a-l]* → pool reward-uat5.123.com_AM2BL
• Patterns /b[m-z]* OR /c[a-d]* → pool reward-uat5.123.com_BM2CD
• default (any other path) → pool reward-uat5.123.com_AA2AL
Potential Logic Concerns
• The rule explicitly sets priority 500, which differs from the requested default priority (omit priority for default behavior). (high confidence)
Overall Summary
The iRule efficiently implements case-insensitive, glob-based matching for the specified path ranges with a clear default fallback. Adjusting or removing the explicit priority 500 will align it with the requested default priority.
F5, Inc. ("F5") disclaims all liability in connection with any output generated by the AI Assistant ("Output") or use thereof, including without limitation any negative business impact caused by your use of Output to administer, direct, configure or control the operation and functioning of any F5 products. Output is provided "as is" without any warranties of any kind.
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