Forum Discussion
Sokol_69126
Nimbostratus
Apr 29, 2016Irule forwarding with various options
Hey Guys,
I've been asked to create a rule forwarding to various places depending on various requests. the options are as follows:
http://www.mysite.com https://www.be...
Stanislas_Piro2
Cumulonimbus
Apr 30, 2016Hi,
instead of multiple if commands, it is recommended to use switch
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] equals "mysite.com" } {
switch -glob [string tolower [HTTP::path]] {
"/" -
"/mysite/" { HTTP::redirect https://www.bettersite.com/mysite/ }
default {
HTTP::redirect https://www.bettersite.com/mysite[HTTP::uri]
return
}
}
} else { HTTP::respond 301 Location https://www.mysite.com[HTTP::uri] return }
}
when appending [HTTP::uri] to a host, do not add / as [HTTP::uri] already starts with /
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects