This should work if both sites are using the same VIP. If they're not using the same VIP you'll want to move the redirect from superbook.discoverypage.com to www.discoverypage.com to its own iRule and assign that to the VIP for superbook.
when HTTP_REQUEST {
if { [HTTP::host] equals "superbook.discoverypage.com" } {
HTTP::respond 301 Location "http://www.discoverypage.com/"
} else {
switch -exact -- [string tolower [HTTP::host]] {
"www.discoverypage.com" {
if {[TCP::local_port] == 80} {
HTTP::respond 301 Location "https://[HTTP::host][HTTP::uri]"
}
elseif { [string tolower [HTTP::uri]] starts_with "/gospels/" } {
if { [string tolower [HTTP::host]] ne "gospels.discoverypage.com" } {
HTTP::respond 301 Location "https://gospels.discoverypage.com[HTTP::uri]"
}
}
}
"discoverypage.com" {
if { [matchclass $::wwwredirects equals [string tolower [HTTP::path]]] } {
HTTP::respond 301 Location "https://www.discoverypage.com[HTTP::uri]"
} elseif { [TCP::local_port] == 80 } {
HTTP::respond 301 Location "https://[HTTP::host][HTTP::uri]"
} elseif { [string tolower [HTTP::uri]] starts_with "/dotnet/excel/114/" || [string tolower [HTTP::uri]] starts_with "/dotnet/excel/102/" } {
HTTP::respond 301 Location "https://www.discoverypage.com[HTTP::uri]"
}
elseif { [string tolower [HTTP::uri]] starts_with "/forumsdotnet/" } {
if { [string tolower [HTTP::host]] ne "forums.discoverypage.com" } {
HTTP::respond 301 Location "https://forums.discoverypage.com[HTTP::uri]"
}
}
}
default {
if { [TCP::local_port] == 80 } {
HTTP::respond 301 Location "https://[HTTP::host][HTTP::uri]"
}
}
}
removed redirect to superbook.discoverypage.com
}