Forum Discussion
eran
Jan 03, 2023Altostratus
irule redirect with partial URI
hi i need some assitance to my current irule that i created to catch a uri and then delete the the folder path and resend the request to another virtual server i have. i have tried to redirect to the...
JRahm
Jan 03, 2023Admin
you're close, but you're missing some brackets around your string tolower as well as the fact that it will never match if you've lowered the letters but are trying to match against an upper in your match string.
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] starts_with "/abc" } {
HTTP::uri [string map {"/abc" ""} [HTTP::uri]]
pool <new pool>
}
}
### alternative
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] starts_with "/abc" } {
HTTP::uri [string range [HTTP::uri] 4 end]
pool <new pool>
}
}
I propose the alternative because it is ever-so-slightly faster per iteration:
% set uri /abc/?doc=9999&cont=1000
/abc/?doc=9999&cont=1000
% time { string range $uri 4 end} 100000
0.6844128599999999 microseconds per iteration
% time { string map {"/abc" ""} $uri} 100000
0.7239472299999999 microseconds per iteration
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