Forum Discussion
Manuel_Rodrigu2
Nimbostratus
Jun 25, 2008Redirect to a different folder hosted by a different pool
Hi there,
Hope this can be done with an iRule. Basically when I receive requests for http://www.abc.com/hello I need to redirect them to http://www.abc.com/hello_1 hosted on a different...
Deb_Allen_18
Jun 25, 2008Historic F5 Account
It's not clear whether you want to redirect or re-write the URI. josantia's solution re-writes the URI, but only for exactly that URI.
If you want to re-write the existing URI by simply replacing the name of the first directory, you can do it like this:
when HTTP_REQUEST {
if {[getfield [string tolower [HTTP::uri]] "/" 2] equals "hello" } {
HTTP::uri [string map {"/hello" "/hello_1"} [HTTP::uri]]
pool my_other_pool
} else {
pool my_default_pool
}
}
If you want to redirect the same way (preserving the URI), you can do it like this:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"/hello1*" { pool my_other_pool }
"/hello*" { HTTP::redirect "http://[HTTP::host]/hello_1[substr [HTTP:uri] 6]" }
default { pool my_default_pool }
}
}
/deb
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
