Forum Discussion
301 Permanent HTTPS redirect
Another method would be to use the switch statement instead of if. If you plan to add additional redirects in the future, it may look a little cleaner...
when HTTP_REQUEST {
switch -glob -- [string tolower [HTTP::host]] {
"cardiosmart.org" -
"*healthandwellness.cardiosmart.org*" {
HTTP::respond 301 Location "XXXXX[HTTP::uri]"
return
}
}
}
Because the code block messes up hyperlinks, replace the XXXXX with https://www.cardiosmart.org.
In this case, the -glob says to allow wildcards in the checks, and you have two conditions (the second which uses the * wildcard) that will cause the HTTP redirect response. With this format, if you needed to add new hosts to redirect, you would just add a - at the end of the healthandwellness line and put the additional host on the next line.
Additional documentation regarding if/elseif/else and switch statements can be found here
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
