Forum Discussion
Logic for iRule on a single VIP to redirect http (80)traffic based upon uri.
I'm creating an iRule on a single VIP to redirect http (80)traffic below as follows.
webmail..com --> 302 redirect to https://outlook.office365.com/owa/sample.net webmail.sample.net --> 302 redirect to https://outlook.office365.com/owa/sample.net webmail.sample.com --> 302 redirect to https://outlook.office365.com/owa/sample.net
onedrive..com --> 302 redirect to https://login.microsoftonline.com/login.srf? onedrive.gsiccorp.net --> 302 redirect to https://login.microsoftonline.com/login.srf? onedrive.gsicommerce.com --> 302 redirect to https://login.microsoftonline.com/login.srf?
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 https://outlook.office365.com/owa/sample.net 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 } } }
- Reginald_Sible1NimbostratusThank you very much for the help!
- Yann_Desmarest_Nacreous
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 } } }
- Reginald_Sible1NimbostratusThank you very much for the help!
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com