Forum Discussion
Daniel_104432
Nimbostratus
Sep 19, 2011How to read a string + value from a data group list
Hello there,
i've got some trouble with a datagroup list. We are using a lot of lists to match strings against client host requests but now I want to use the value of the matched string for a red...
Michael_Yates
Nimbostratus
Sep 19, 2011Hi Daniel,
I created an example for you. In my example I capture the "-value" of a matching "-name" and store it in a variable. In the if statement, if a match was found and the value is not empty then it will redirect to the location.
I am providing the Data Group and the iRule so that you can make modifications and test with hit.
class string_value_test_group {
{
"/foo" { "http://www.yahoo.com" }
"/foofoo" { "http://www.google.com" }
"/foofoofoo" { "http://www.msn.com" }
}
}
when HTTP_REQUEST {
set redirecturl [class match -value [string tolower [HTTP::uri]] starts_with string_value_test_group ]
if { $redirecturl ne "" } {
HTTP::respond 301 Location $redirecturl
}
}
Hope this helps.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
