Forum Discussion
Steve_M__153836
Nimbostratus
Jul 14, 2015iRule Help - Capture URI, Modify, and Redirect
I have two sets of incoming URLs I need to pick apart and redirect based on their content. Both with the same formatting.
https://my.site.org/A/B/find-a-thing1/garbage
https://my.site.org/A/B/fin...
Kevin_Stewart
Employee
Jul 14, 2015You're probably on the right track with the scan command. TCL scan takes three primary arguments: the string to evaluate, format specifier, and the arbitrary variables to "dump" scanned string values.
So for example, let's take your second URI:
set tmp1 "/A/B/find-a-thing1/thing1detail/actualthing1/garbage"
To scan out each of the URI components into separate variables, it might look something like this:
scan $tmp1 {/%[^/]/%[^/]/%[^/]/%[^/]/%[^/]/%[^/]} a b c d e f
The "%[^/]" specifier says to take all of the characters that are not a forward slash "/" and assign those to one of the variables at the end. With 6 URI components, this dumps each into a separate variable (a-f).
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