Forum Discussion
irule help based on uri
Hi
You could do something like
when HTTP_REQUEST {
if {[HTTP::uri] starts_with "/live"}{
pool pool_live
} elseif {[HTTP::uri] starts_with "/test"}{
pool pool_test
}
}Im sorry to move the goalposts but my brief has changed to the following now:
we have one VIP that hostname site.abc.com resolves to, if user visits https://site.abc.com/live it should redirect to pool "pool_live" changing the ur toi "/live_site". If user visits https://site.abc.com/test it should redirect to pool "pool_test" changing the uri to /test_site.
Is this achievable?
- Sep 04, 2019
Hi cymru81,
iRule:
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "site.abc.com" } { switch -glob [string tolower [HTTP::uri]] { "/live" { HTTP::uri "/live_site" pool pool_live } "/test" { HTTP::uri "/test_site" pool pool_test } } } }iRule with redirect:
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "site.abc.com" } { switch -glob [string tolower [HTTP::uri]] { "/live" { HTTP::redirect "https://site.abc.com/live_site" pool pool_live } "/test" { HTTP::redirect "https://site.abc.com/test_site" pool pool_test } } } }If the HTTP::host is not site.abc.com, you can reject requests.
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
