Forum Discussion
Dennis_Goss_70_
Nimbostratus
Dec 21, 2015iRule redirect but need some of the original PATH
Relatively new to iRules but have done a ton of scripting (PoSh, vbs, etc...) and understand the basics and have studied the http::uri, http::path and http::query built-in variables - thanks in advan...
Kai_Wilke
MVP
Dec 21, 2015Hi 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
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