Mark_58017
Jan 04, 2016Nimbostratus
The old 'Operation not supported. Multiple redirect/respond invocations not allowed' chestnut
Hi,
So this iRule kind of evolved and it seems it always had the multiple invocation error issue. So I changed the logic to break out the final default https redirect. The problem is it clashes with the default on the switch. The problem is that the site is really convoluted and I cannot get rid of the final redirect and without the default on the switch I lose the redirect for http://www.bobsite.co.uk/ to https. I don't see why? I should be bale to remove the default statement on the switch and just hit the else at the end.
when CLIENT_ACCEPTED {
set DEFAULT_POOL [LB::server pool]
}
when HTTP_REQUEST {
# Setting the Initial Variables
set DEBUG 0
set LOG_PREFIX [IP::client_addr]
set HOST [string tolower [HTTP::host]]
set URI [string tolower [HTTP::uri]]
if {$HOST eq "m.bobsite.co.uk"} {
if {[class match $URI starts_with m.bobsite.co.uk]} {
set URI [class match -value -- $URI starts_with m.bobsite.co.uk]
if { $DEBUG } { log local0. "$LOG_PREFIX: Redirecting to https://www.bobsite.co.uk/$URI" }
HTTP::respond 301 location "https://www.bobsite.co.uk$URI"
} else {
HTTP::respond 301 Location "https://www.bobsite.co.uk"
}
mediaroom.bobsite.co.uk
} elseif {$HOST eq "mediaroom.bobsite.co.uk"} {
HTTP::respond 301 Location "https://www.bobsite.co.uk/about/media-room"
Convert the hostname "bobsite.co.uk" or "bobsite.com" to "www.bobsite.co.uk"
} elseif { (($HOST eq "bobsite.co.uk") || ($HOST contains "bobsite.com")) } {
HTTP::respond 301 location "https://www.bobsite.co.uk[HTTP::uri]"
} elseif {$HOST eq "www.bobsite.co.uk"} {
Convert the URI based on a match in the datagroup
if {[class match $URI eq www.bobsite.co.uk_v2]} {
set URI [class match -value -- $URI eq www.bobsite.co.uk_v2]
if { $DEBUG } { log local0. "$LOG_PREFIX: Redirecting to https://$HOST$URI" }
HTTP::respond 301 location "https://$HOST$URI"
}
Dealing with the edge cases
switch -glob $URI {
"/2for1-london" { HTTP::respond 301 Location "https://www.bobsite.co.uk/stations-destinations/train-to" }
"/about/careers/" { HTTP::respond 301 Location "http://www.bobsitecareers.co.uk/brochure/" }
"/about/careers" { HTTP::respond 301 Location "http://www.bobsitecareers.co.uk/Brochure/" }
"/about/careers/faqs.aspx" { HTTP::respond 301 Location "http://www.bobsitecareers.co.uk/brochure/" }
"/careers/" { HTTP::respond 301 Location "http://www.bobsitecareers.co.uk/Brochure/" }
"/careers" { HTTP::respond 301 Location "http://www.bobsitecareers.co.uk/brochure/" }
"/contact_us/jobs/default.aspx" { HTTP::respond 301 Location "http://www.bobsitecareers.co.uk/brochure/" }
"/livechat" { HTTP::respond 301 Location "https://webchat.bobinteractive.com/start.jsp?workgroup=vt@workgroup.livechat.bobinteractive.com&location=https://www.bobsite.co.uk/livechat" }
"/livechat/" { HTTP::respond 301 Location "https://webchat.bobinteractive.com/start.jsp?workgroup=vt@workgroup.livechat.bobinteractive.com&location=https://www.bobsite.co.uk/livechat" }
"/tasty" { HTTP::respond 301 Location "https://www.buytickets.bobsite.co.uk/buytickets/advancedsearch.aspx" }
default { HTTP::respond 301 Location "https://[HTTP::host][HTTP::uri]" }
}
If no match send to https
} else {
HTTP::respond 301 Location "https://[HTTP::host][HTTP::uri]"
}
unset DEBUG
unset LOG_PREFIX
unset HOST
unset URI
}
If anyone can spot what's going on that would be great. I want to avoid breaking the switch into if statements.
Thanks