Joe_Pipitone
May 12, 2014Nimbostratus
Portion of iRule not being processed
I have combined multiple iRules into one, however the 2nd portion of the rule is not working. I have confirmed using logging that the URI is being caught, however redirection is not taking place. I believe I may not be nesting switch statements correctly.
I have commented which parts of the script are working, and which section is not. Can anyone point me in the right direction?
when HTTP_REQUEST {
These DO work
if { ([HTTP::host] equals "olddomain.com") } {
switch -glob [HTTP::host] {
"/" { HTTP::redirect "http://newdomain.com" }
default { HTTP::redirect "http://newdomain.com[HTTP::uri]" }
}
}
These do NOT work
switch -glob [string tolower [HTTP::host]] {
"oldforum.olddomain.com" {
Check the URI, set to lowercase
switch [string tolower [HTTP::query]] {
"TID=" {
HTTP::redirect "https://newforum.newdomain.com/default.aspx?g=posts&t=[URI::query [HTTP::uri] TID]"
return
}
"FID=" {
HTTP::redirect "https://newforum.newdomain.com/default.aspx?g=topics&f=[URI::query [HTTP::uri] FID]"
return
}
"C=" {
HTTP::redirect "https://newforum.newdomain.com/default.aspx?g=forum&c=[URI::query [HTTP::uri] C]"
return
}
}
}
These DO work
"*newdomain.com" - "*olddomain.com" {
switch -glob [string tolower [HTTP::uri]] {
"/someuri" {
HTTP::redirect "http://newdomain.com/path-to/page.aspx"
return
}
"/someuri2" {
HTTP::redirect "http://http://newdomain.com/path-to/page.aspx"
return
}
}
}
}
}