Forum Discussion
paulfish
Nimbostratus
Sep 01, 2015Remove first element of uri
Hi,
I'm looking to remove the first element of a URI.
This is what I got from searching this site and it works.
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/css" } {
...
Brad_Parker
Cirrus
Sep 01, 2015Updated and tested in my lab, this could work for you.
when HTTP_REQUEST {
set uri "/[getfield [HTTP::uri] "/" 2]/"
HTTP::uri [string map " $uri / " [HTTP::uri]]
}
It will remove the first folder in the URI path.
Brad_Parker
Cirrus
Sep 01, 2015Pool selection can be done either with a switch or a datagroup. A datagroup will scale easier as you will just have to add all your root apps like css to the data group to have pool selection based on it.
Switch:
when HTTP_REQUEST {
set uri "/[getfield [HTTP::uri] "/" 2]/"
HTTP::uri [string map " $uri / " [HTTP::uri]]
switch [getfield [HTTP::uri] "/" 2] {
"css" -
"apps" -
"containers" {
pool [getfield [HTTP::uri] "/" 2]
}
default {
pool *default_pool*
}
}
}
Datagroup:
when HTTP_REQUEST {
set uri "/[getfield [HTTP::uri] "/" 2]/"
HTTP::uri [string map " $uri / " [HTTP::uri]]
if { [class match [getfield [HTTP::uri] "/" 2] equals *datagroupname*] }{
pool [getfield [HTTP::uri] "/" 2]
}
}
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