Forum Discussion
Darrin_Wiens_25
Nimbostratus
Apr 29, 2008Redirect to Multiple URLs
I am in the process of moving from a Cisco CSS to the F5 and I have an interesting Redirect issue. On the CSS, I have a content rule that has two services associated with it. Each service is of a re...
Apr 29, 2008
This should work for you.
when RULE_INIT {
set ::whichone 0
}
when HTTP_REQUEST {
switch $::whichone {
0 {
HTTP::redirect "http://Server1/blah"
}
1 {
HTTP::redirect "http://Server2/blah"
}
}
set ::whichone [expr ! $::whichone]
}Basically it's setting a global variable and toggles it between 0 and 1 on each http request. Then, depending on the current value it issues the appropriate redirect.
Or, you could do the same without the expr command and using a default case to avoid a second comparison on the value 1.
when RULE_INIT {
set ::whichone 0
}
when HTTP_REQUEST {
switch $::whichone {
0 {
HTTP::redirect "http://Server1/blah"
set ::whichone 1
}
default {
HTTP::redirect "http://Server2/blah"
set ::whichone 0
}
}
}Hope this helps...
-Joe
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
