Forum Discussion
wlepkin_98758
Jan 30, 2012Nimbostratus
string trimleft, and assigning HTTP::uri
Hi --
I'm trying to use the 'string trimleft' function to change the URI, and must be doing something wrong. Here's what I've got, with lots of log statements so I can see what's going on: ...
hooleylist
Jan 30, 2012Cirrostratus
string trimleft operates by removing characters not words. So a is part of the characters you have in your "trim" list so it's removed from the source string. If you want to chop off /chart, you could use string range or scan:
string range [HTTP::uri] 7 end
scan [HTTP::uri] {/charts%s}
string range should be more efficient:
% time {string range $uri 7 end} 1000
1 microseconds per iteration
%
% time {scan $uri {/charts%s}} 1000
2 microseconds per iteration
Also, the value for HTTP::uri, HTTP::path and other HTTP:: commands was cached in the same iRule and event in 9.x and 10.x. This was fixed in v11. Until you upgrade to v11, you'll see the original value when logging, modifying and then logging the values for the HTTP:: commands. The value is actually changed though.
when HTTP_REQUEST {
if {[string tolower [HTTP::uri]] starts_with "/charts"}{
HTTP::redirect "http://ifp-vip:8080[string range [HTTP::uri] 7 end]"
log local0. "redirecting to http://ifp-vip:8080[string range [HTTP::uri] 7 end]"
}
}
Aaron
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