Forum Discussion
iRule to change a take a URL and add URI then send to a Pool.
Hi Everyone,
I have a simple pool selection iRule in place for some internal sites but have been asked to have a URI added at the end to make it easier for people to access. I currently have:
when HTTP_REQUEST {
switch [string tolower [HTTP::host]] {
"sharepoint.test-site.com" {
pool /Internal/F5-Internal-Pool_sharepoint
}
default {
discard
}
}
}
and I would like merge it with something along the lines of :
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] equals "/" } {
HTTP::redirect "https://[HTTP::host]/Pages/default.aspx"
}
}
How would I merge these two together?
Try this one:
when HTTP_REQUEST { switch [string tolower [HTTP::host]] { "sharepoint.test-site.com" { if { [HTTP::uri] equals "/" } { HTTP::redirect "https://[HTTP::host]/Pages/default.aspx" } else { pool /Internal/F5-Internal-Pool_sharepoint } } default { discard } } }
4 Replies
- Cory_50405
Noctilucent
Try this one:
when HTTP_REQUEST { switch [string tolower [HTTP::host]] { "sharepoint.test-site.com" { if { [HTTP::uri] equals "/" } { HTTP::redirect "https://[HTTP::host]/Pages/default.aspx" } else { pool /Internal/F5-Internal-Pool_sharepoint } } default { discard } } } - Lazaro_Pereira_
Nimbostratus
Any performance impact using if with switch? I just started with iRules and in the 101 they mention how its better to use switch rather than if.
- Cory_50405
Noctilucent
I don't think you'll encounter any performance issues with the if inside of the switch. Plus it gives you additional flexibility down the road if you want to expand your iRule.
- Lazaro_Pereira_
Nimbostratus
Thanks it worked like a dream!
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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