Forum Discussion
Kai_Wilke
Dec 21, 2015MVP
Hi Dennis,
the
[switch]
command is ideal for content switching scenarios, where you have to evaluate 10-50 different URLs in a first-match condition. If you need to evaluate less than 10 different URLs, then the [if]
command would have some minor performance benefits, but would be a little more complex. And if you need to evaluate more than 50 different URLs, then the [class]
command in combination with data groups may come to its shine!
The
[string tolower [HTTP::uri]]
in combination with -glob
is also a very beginner friendly way to parse the URLs, since it may contain easy to understand String-Wildcards *
or Single-Letter-Wildcards $
which can be used as a trailing or leading wildcards, in combination with each other or even for both sides or in between of an URL search string.
A
[switch]
based [HTTP::uri]
evaluation followed by an redirect would look like that...
when HTTP_REQUEST {
switch -glob -- [string tolower [HTTP::uri]] "*/shared%20documents/mine.docx*" {
HTTP::redirect "/sites/corpcomm/Shared%20Documents/Mine.docx?OpenDocument"
} "*/corporatecommunications/shared%20documents/*" {
HTTP::redirect "/sites/corpcomm/Shared%20Documents/"
} default {
Do nothing or select a pool
}
}
Cheers, Kai