Forum Discussion
Joe_Pipitone
Nimbostratus
Aug 04, 2010Combining iRules -> switch statements
I have a master iRule which is doing simple redirecting based on http::uri
I would like to add an additional set of rules that tries to do a string match for a specific URI typed in, such as:
...
hoolio
Cirrostratus
Aug 04, 2010Hi Joe,
You can nest switch cases as shown below. I've split out the host and URI check you were trying to do together into separate switch cases. Also, you don't need an explicit return statement in each switch case. Once a switch case matches, no other switch cases in the same statement will be evaluated.
when HTTP_REQUEST {
Check the Host header value, set to lowercase
switch -glob [string tolower [HTTP::host]] {
"events.oursite.com" {
Check the URI, set to lowercase
switch [string tolower [HTTP::uri]] {
"/event.aspx?event=someevent2010" {
HTTP::redirect "https://sub.domain.com/events/some-url-2010/home.aspx"
}
}
}
"*somedomain1.*" {
HTTP::redirect "https://somesite.com/EventOverview.aspx?Event=someevent1"
}
"*somedomain2.*" {
HTTP::redirect "https://anothersite.com/EventOverview.aspx?Event=someevent2"
}
"*somedomain3.*" {
HTTP::redirect "https://oursite.com"
}
}
}
Aaron
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