Forum Discussion
Need Help with iRule
Example URL:
The iRule needs to be able to locate the 7th "chunk" of the URI, add a period (.) to the end of it and re-insert it back into the URI before passing it back to the pool. "Chunks" are separated by the forward slash within the URI, so in this case, the 7th "chunk" begins with "/MTUxMzV8...". I'm not sure if this can be done with regex within an iRule but thought I would throw it out there to see if anyone had any thoughts on this.
Any help is greatly appreciated!
- JustCooLpOOLe
Cirrocumulus
This regex finds the string I'm looking for:
(?:.*?\/){7}([^\/?]+)
- JRahm
Admin
regex should be avoided at all cost. A simple string map would be appropriate here. Just in the tcl shell, this is accomplished with an lindex/split (you can use getfield in an iRule which is just an lindex/split shortcut):
% set x "/t/BA/CkA/E2I/ABqYWA/AA/MTUxMzV8aHR0cHM6Ly9wcm8ubW9uZXltYXBwcmVzcy5jb20vbS83ODM4MzM-ZW1haWw9Sk9ITiU0MDE0d2VzdGl0Lm9ubWljcm9zb2Z0LmNvbSZhPTQmbz0yNjI0JnM9NDk2MiZ1PTE3NDI5MzYmbD0xNTEzNSZyPU1DMiZ2aWQ9NDJjTGZKJmc9MA/AQ/fWN2" /t/BA/CkA/E2I/ABqYWA/AA/MTUxMzV8aHR0cHM6Ly9wcm8ubW9uZXltYXBwcmVzcy5jb20vbS83ODM4MzM-ZW1haWw9Sk9ITiU0MDE0d2VzdGl0Lm9ubWljcm9zb2Z0LmNvbSZhPTQmbz0yNjI0JnM9NDk2MiZ1PTE3NDI5MzYmbD0xNTEzNSZyPU1DMiZ2aWQ9NDJjTGZKJmc9MA/AQ/fWN2 % set y [lindex [split $x /] 7] MTUxMzV8aHR0cHM6Ly9wcm8ubW9uZXltYXBwcmVzcy5jb20vbS83ODM4MzM-ZW1haWw9Sk9ITiU0MDE0d2VzdGl0Lm9ubWljcm9zb2Z0LmNvbSZhPTQmbz0yNjI0JnM9NDk2MiZ1PTE3NDI5MzYmbD0xNTEzNSZyPU1DMiZ2aWQ9NDJjTGZKJmc9MA % string map [list ${y} ${y}.] $x /t/BA/CkA/E2I/ABqYWA/AA/MTUxMzV8aHR0cHM6Ly9wcm8ubW9uZXltYXBwcmVzcy5jb20vbS83ODM4MzM-ZW1haWw9Sk9ITiU0MDE0d2VzdGl0Lm9ubWljcm9zb2Z0LmNvbSZhPTQmbz0yNjI0JnM9NDk2MiZ1PTE3NDI5MzYmbD0xNTEzNSZyPU1DMiZ2aWQ9NDJjTGZKJmc9MA./AQ/fWN2
In the iRule, it will consolidate to something like this:
set uri_chunk [getfield [HTTP::uri] / 8] string map [list ${uri_chunk} ${uri_chunk}.] [HTTP::uri]
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