Forum Discussion

Kevin_Smith_01_'s avatar
Kevin_Smith_01_
Icon for Nimbostratus rankNimbostratus
Aug 22, 2013

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

  • 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=-

    • JRahm's avatar
      JRahm
      Icon for Admin rankAdmin
      yep, that's an iRule. Can also be done with an http class (pre-v11.4) or a policy (v11.4+)