Forum Discussion
Domai_23823
Nimbostratus
May 09, 2018URI redirect iRule review/Help
Hello Guys,
I have a question or review request for the below iRule. let me tell you about the requirement first.
The user needs redirect to any URI that starts with /monkey/* BUT does...
Samir_Jha_52506
Noctilucent
May 09, 2018Did some modification in irule. Either use
start_with or contains
place of eq
in syntex. It will work. Please let us know if any issue
when HTTP_REQUEST {
if { ([string tolower [HTTP::host]] eq "main.you.com") and ([string tolower [HTTP::uri]] starts_with "/monkey/std/public/v1") } {
HTTP::redirect "https://main.you.com/monkey/std/public/v1"
}
elseif { ([string tolower [HTTP::host]] eq "main.you.com") and ([string tolower [HTTP::uri]] starts_with "/monkey/public/v2") } {
HTTP::redirect "https://main.you.com/monkey/public/v2"
}
elseif { ([string tolower [HTTP::host]] eq "main.you.com") and ([string tolower [HTTP::uri]] starts_with "/monkey/*") } {
HTTP::redirect "https://side.you.com" }
else { pool main.you.com_pool }
}
- DomaiMay 09, 2018
Altostratus
Thank you f5_rock I tried contains or start_with it did not work. It goes into a loop.
- Nandhini_NataraMay 09, 2018
Nimbostratus
Hello Domai,
Please try with below irule
when HTTP_REQUEST {
if { ([string tolower [HTTP::host]] starts_with "main.you.com") and ([string tolower [HTTP::uri]] starts_with "/monkey/std/public/v1") } { HTTP::redirect "[https://main.you.com/monkey/std/public/v1"](https://main.you.com/monkey/std/public/v1); } elseif { ([string tolower [HTTP::host]] starts_with "main.you.com") and ([string tolower [HTTP::uri]] starts_with "/monkey/public/v2") } { HTTP::redirect "[https://main.you.com/monkey/public/v2"](https://main.you.com/monkey/public/v2); } elseif { ([string tolower [HTTP::host]] starts_with "main.you.com") and ([string tolower [HTTP::uri]] starts_with "/monkey/") } { HTTP::redirect "[https://side.you.com"](https://side.you.com); } else { pool main.you.com_pool }
}
- DomaiMay 09, 2018
Altostratus
Nandhini I tried that with both "starts_with" and "contains" it did not work as intended. Jie's iRule did work.
- Nandhini_NataraMay 10, 2018
Nimbostratus
Sorry Domai My bad. I don't know how URL has been two times added after http::redirect.
when HTTP_REQUEST {
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