Hi Charles,
as already outlined by David, a if { [string length [substr [HTTP::uri] 0 "?"]] > 0 } will make no sense at all, since the used
[substr]
command will extract portion from the beginning of the
[HTTP::uri]
until the first ocourence of a question mark. This will be always at least a
/
char, which would then resolve to a
[string length]
value of at least
1
.
To check if a HTTP query string (the portion after the first
?
character) is present you may use one of the iRule snippets below...
Example1: Using a rather simple if { X contain Y } then { }
syntax.
if { [HTTP::uri] contains "?" } then {
A query string is present
} else {
A query string is NOT present
}
Example2: Using F5s [HTTP::query]
command to extract the URI query string.
if { [HTTP::query] ne "" } then {
A query string is present
} else {
A query string is NOT present
}
Note: The difference of the two syntaxes is, that the first example will also identify empty query strings (e.g. /somepath?
) and the seconds example will only identify query strings with valid parameters (e.g. /somepath?param=1
).
Cheers, Kai