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
}
}
}