Forum Discussion
David_X_20743
Nimbostratus
Jul 24, 2008HTTP URI redirect
Hi
I am not sure if the following http uri redirect is possible or not.
Please give me a hint. Thanks
when the client request
http://test.com/test...
hoolio
Cirrostratus
Jul 24, 2008Something like this?
when RULE_INIT {
Initialize a global counter
set ::redirect_counter 1
}
when HTTP_REQUEST {
Check if URI is /test.html
if {[HTTP::uri] eq "/test.html"}{
Redirect client according to the counter value
HTTP::redirect "http://[HTTP::host]/test${::redirect_counter}"
Increment the counter
incr ::redirect_counter
Reset the counter if it's over the limit
if {$::redirect_counter > 3}{
set ::redirect_counter 1
}
}
}
If the URI's don't literally ending with a number, you could use something like this:
when RULE_INIT {
Initialize a global counter
set ::redirect_counter 1
}
when HTTP_REQUEST {
Check if URI is /test.html
if {[HTTP::uri] eq "/test.html"}{
Redirect client according to the counter value
switch $::redirect_counter {
1 {
HTTP::redirect "http://[HTTP::host]/testUrlOne"
}
2 {
HTTP::redirect "http://[HTTP::host]/testUrlTwo"
}
3 {
HTTP::redirect "http://[HTTP::host]/testUrlThree"
}
}
Increment the counter
incr ::redirect_counter
Reset the counter if it's over the limit
if {$::redirect_counter > 3}{
set ::redirect_counter 1
}
}
}
Aaron
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
