Forum Discussion
CraigM_17826
Altocumulus
Jan 06, 2012parsing a datagroup/class
Hi all,
I have this situation. Our iRule for our main website now has a lot of redirects which are based on the URI specified. There are now getting to be quite a few of these and for vari...
hoolio
Cirrostratus
Jan 06, 2012Hi Craig,
Here's an example which looks up the client's requested path (the /path/to/file.html in /path/to/file.html?param=value...). It does an exact match, but you could alter that by changing equals to starts_with.
when HTTP_REQUEST {
Check the requested path, set to lower case to see if it exists in the uri_map_dg datagroup
If there is a match, save the corresponding value
set new_path [class match -value -- [string tolower [HTTP::path]] equals uri_map_dg]
If there was a matching path, update the requested path
if {$new_path ne ""}{
HTTP::path $new_path
}
}Here's an example for starts_with logic:
when HTTP_REQUEST {
Check the requested path, set to lower case to see if it exists in the uri_map_dg datagroup
If there is a match, save the corresponding name and value to do the update
set old_and_new_path [class match -element -- [string tolower [HTTP::path]] starts_with uri_map_dg]
If there was a matching path, update the requested path
Use string map to replace the old with the new in the path
if {$new_path ne ""}{
HTTP::path [string map $old_and_new_path [HTTP::path]]
}
}Aaron
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
