Forum Discussion
Host redirection not working for second host in iRule
- Feb 05, 2022
You may try Daniel_Wolf solution but your iRule has clear mistakes as the second "if" statement is in the first "if" statemet.
when HTTP_REQUEST {
if {[HTTP::host] equals "test.com" and [HTTP::uri] equals "/"} {
HTTP::redirect "https://test.com/redlab/login.htmll" }
if {[HTTP::host] equals "lab.com" and [HTTP::uri] equals "/"} {
HTTP::redirect "https://lab.com/bluelab/login.html"}
}or even better
when HTTP_REQUEST {
if {[HTTP::host] equals "test.com" and [HTTP::uri] equals "/"} {
HTTP::redirect "https://test.com/redlab/login.htmll"
}elseif {[HTTP::host] equals "lab.com" and [HTTP::uri] equals "/"} {
HTTP::redirect "https://lab.com/bluelab/login.html"}
}Alse this free article for writting irules (the "then" statement is just optional):
https://community.f5.com/t5/technical-articles/irules-101-02-if-and-expressions/ta-p/283431
You may try Daniel_Wolf solution but your iRule has clear mistakes as the second "if" statement is in the first "if" statemet.
when HTTP_REQUEST {
if {[HTTP::host] equals "test.com" and [HTTP::uri] equals "/"} {
HTTP::redirect "https://test.com/redlab/login.htmll" }
if {[HTTP::host] equals "lab.com" and [HTTP::uri] equals "/"} {
HTTP::redirect "https://lab.com/bluelab/login.html"}
}
or even better
when HTTP_REQUEST {
if {[HTTP::host] equals "test.com" and [HTTP::uri] equals "/"} {
HTTP::redirect "https://test.com/redlab/login.htmll"
}elseif {[HTTP::host] equals "lab.com" and [HTTP::uri] equals "/"} {
HTTP::redirect "https://lab.com/bluelab/login.html"}
}
Alse this free article for writting irules (the "then" statement is just optional):
https://community.f5.com/t5/technical-articles/irules-101-02-if-and-expressions/ta-p/283431
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