I’m creating an iRule on a single VIP to redirect http (80)traffic below as follows.
webmail..com --> 302 redirect to Outlook webmail.sample.net --> 302 redirect to Outlook webmail.sample.com --> 302 redirect to Outlook
onedrive..com --> 302 redirect to Sign in to your account? onedrive.gsiccorp.net --> 302 redirect to Sign in to your account? onedrive.gsicommerce.com --> 302 redirect to Sign in to your account?
Can someone assist me with what my logic would look like. I’m a little unsure on my else if statements.
I was thinking:
When HTTP_Request { if{ [HTTP::header Host] == “www.sample.com” }{ pool pl_Sample -NOT POOL-I want a URL Outlook elseif{ [HTTP::header Host] == “www.sample2.com” }{ pool pl_Sample -NOT POOL-I want a URL-https://outlook.office365.com/owa/sample2.net elseif{ [HTTP::header Host] == “www.sample2.com” }{ pool pl_Sample --NOT POOL-I want a URL-https://outlook.office365.com/owa/sample3.net drop
When HTTP_Request {
if { [HTTP::Host] contains "webmail.com" } {
HTTP::respond 302 Location "https://outlook.office365.com/owa/sample.net"
} elseif { [HTTP::Host] contains "webmail.sample.com" } {
HTTP::respond 302 Location "https://outlook.office365.com/owa/sample.net"
} elseif { [HTTP::Host] contains "onedrive.com" } {
HTTP::respond 302 Location "https://login.microsoftonline.com/login.srf?"
} else {
reject
}
}
Or you can preferably use a switch command :
When HTTP_Request {
switch -glob [HTTP::host] {
"webmail.com*" -
"webmail.sample.com" {
HTTP::respond 302 Location "https://outlook.office365.com/owa/sample.net"
}
"onedrive.com*" {
HTTP::respond 302 Location "https://login.microsoftonline.com/login.srf?"
}
default { reject }
}
}
When HTTP_Request {
if { [HTTP::Host] contains "webmail.com" } {
HTTP::respond 302 Location "https://outlook.office365.com/owa/sample.net"
} elseif { [HTTP::Host] contains "webmail.sample.com" } {
HTTP::respond 302 Location "https://outlook.office365.com/owa/sample.net"
} elseif { [HTTP::Host] contains "onedrive.com" } {
HTTP::respond 302 Location "https://login.microsoftonline.com/login.srf?"
} else {
reject
}
}
Or you can preferably use a switch command :
When HTTP_Request {
switch -glob [HTTP::host] {
"webmail.com*" -
"webmail.sample.com" {
HTTP::respond 302 Location "https://outlook.office365.com/owa/sample.net"
}
"onedrive.com*" {
HTTP::respond 302 Location "https://login.microsoftonline.com/login.srf?"
}
default { reject }
}
}
Thank you very much for the help!
Thank you very much for the help!