Forum Discussion
Joe_Pipitone
Aug 04, 2010Nimbostratus
Combining 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:
http://events.oursite.com/Event.aspx?Event=someevent2010
I cannot, for the life of me, figure out how to integrate this rule into my existing rules, which look like so:
(sorry for the formatting, forums don't like http links)
when HTTP_REQUEST {
set h [HTTP::host]
set u [HTTP::uri]
switch -glob $h {
"*somedomain1.*"
{
HTTP::redirect "https://somesite.com/EventOverview.aspx?Event=someevent1"
return
}
"*somedomain2.*"
{
HTTP::redirect "https://anothersite.com/EventOverview.aspx?Event=someevent2"
return
}
"*somedomain3.*"
{
HTTP::redirect "http://oursite.com"
return
}
}
}
I have tried the following, and for some reason it doesn't seem to catch it. Can anyone help me with this string match, string to lower problem?
when HTTP_REQUEST {
set h [HTTP::host]
set u [HTTP::uri]
switch -glob [string tolower [HTTP::uri]] {
"events.oursite.com/Event.aspx?Event=someevent2010"
{
HTTP::redirect "http://sub.domain.com/events/some-url-2010/home.aspx"
}
}
switch -glob $h {
"*somedomain1.*"
{
HTTP::redirect "https://somesite.com/EventOverview.aspx?Event=someevent1"
return
}
"*somedomain2.*"
{
HTTP::redirect "https://anothersite.com/EventOverview.aspx?Event=someevent2"
return
}
"*somedomain3.*"
{
HTTP::redirect "http://oursite.com"
return
}
}
}
- hooleylistCirrostratusHi Joe,
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" } } }
- Joe_PipitoneNimbostratusAwesome - I will try this out right now, thank you for your help!
- viper_113332Nimbostratushello all,
- The_BhattmanNimbostratusHi Viper,
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