Forum Discussion
I need to check 4 different headers and re-direct
o-zone.ou.edu > https://ozone.ou.edu 0zone.ou.edu > https://ozone.ou.edu ouzone.ou.edu> https://ozone.ou.edu zone.ou.edu> https://ozone.ou.edu
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] contains "o-zone.ou.edu" } {
HTTP::redirect "https://ozone.ou.edu"
} if { [string tolower [HTTP::host]] contains "0zone.ou.edu" } {
HTTP::redirect "https://ozone.ou.edu"
}
} if { [string tolower [HTTP::host]] contains "ouzone.ou.edu" } {
HTTP::redirect "https://ozone.ou.edu"
}
} if { [string tolower [HTTP::host]] contains "zone.ou.edu" } {
HTTP::redirect "https://ozone.ou.edu"
}
}
7 Replies
- Gary_Bristol_19
Nimbostratus
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "o-zone.ou.edu" } { HTTP::redirect "https://ozone.ou.edu" } if { [string tolower [HTTP::host]] equals "0zone.ou.edu" } { HTTP::redirect "https://ozone.ou.edu" } if { [string tolower [HTTP::host]] equals "ouzone.ou.edu" } { HTTP::redirect "https://ozone.ou.edu" } if { [string tolower [HTTP::host]] equals "zone.ou.edu" } { HTTP::redirect "https://ozone.ou.edu" } } - arpydays
Nimbostratus
this may be more efficient, I've added a default handling also.
when HTTP_REQUEST { switch [string tolower [HTTP::host]] { "o-zone.ou.edu" - "0zone.ou.edu" - "ouzone.ou.edu" - "zone.ou.edu" { HTTP::redirect "https://ozone.ou.edu" } default { pool xxx } } } - Gary_Bristol_19
Nimbostratus
so what does the Default xxx do
- Gary_Bristol_19
Nimbostratus
or it could be written this way ? when HTTP_REQUEST { switch [string tolower [HTTP::host]] { "o-zone.ou.edu" || "0zone.ou.edu" || "ouzone.ou.edu" || "zone.ou.edu" { HTTP::redirect "https://ozone.ou.edu" } default { pool xxx } } }
- Gary_Bristol_19
Nimbostratus
when HTTP_REQUEST { switch [string tolower [HTTP::host]] { "o-zone.ou.edu" || "0zone.ou.edu" || "ouzone.ou.edu" || "zone.ou.edu" { HTTP::redirect "https://ozone.ou.edu" } default { pool xxx } } } - arpydays
Nimbostratus
no, check out the wiki for switch syntax https://devcentral.f5.com/articles/irules-101-04-switch
the default condition is what happens if the other conditions do not get matched, in the example send to pool named abc, it could be other actions e.g. reject or drop
cheers
- Stanislas_Piro2
Cumulonimbus
Hi,
If you are in version 11.4.0 or above, try using Local Traffic Policies... (menu Policies below virtual server in WebUI)
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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