Forum Discussion
Use a wildcard to redirect traffic
I want to redirect traffic to different servers depending on text in the URL after the domain name. We want the same domain name for multiple applications that run on different servers. So for example,
xyz.company.com/123 should go to server 1 and server 2 xyz.company.com/456 should go to server 1 and server 2 xyz.company.com/* should go to server 3 and server 4
Where * is a wildcard and matches any other strings. We want to use a wildcard (*) for the last rule so that anything that does not match the first two rules will be redirected to server 3 and 4. There are 15 or more URL strings and we don't want to code rules for all of them.
3 Replies
- The_Bhattman
Nimbostratus
Hi Kevin Smith 01, You can do this by the following example
when HTTP_REQUEST { switch -glob [string tolower [HTTP::path]] { "/123"-"/456" { pool pool_server1_server2 } default { pool pool_server3_server4 } } }I hope this helps
-=Bhattman=-
- Kevin_Smith_01_
Nimbostratus
Thanks. I assumed this could be done. I am new to F5. Is this considered an iRule?
- JRahm
Admin
yep, that's an iRule. Can also be done with an http class (pre-v11.4) or a policy (v11.4+)
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