Forum Discussion

breddy_11660's avatar
breddy_11660
Icon for Nimbostratus rankNimbostratus
Jun 15, 2012

irules to redirect based on simple pay-per-click 'tags'

We have a pair of BIG-IP F5 Load Balancers, running 10x+, which direct traffic between two web farms.

 

 

 

Farm A) handles default traffic, 404s, etc

 

Farm B) handles a more limited set of CMS based pages

 

 

 

We have a request to support a PPC campaign, based on a limited set of URL characteristics,

 

along the lines of:

 

 

 

*RefID*

 

*TrkNum*

 

 

 

 

Some example URL's would resemble the following

 

 

 

http://www.domain1.com/filename?RefID=$string

 

http://www.domain2.com/path/filename?RefID=$string

 

http://www.domain3.com/path/to/filename?TrkNum=$string

 

 

 

 

 

The hope is that a *pattern* iRule can be created which will allow ANY request with *RefID* or *TrkNum* to be redirected from Webserver Farm A to Webserver Farm B.

 

 

 

Initially this doesn't look feasible however, as the iRule logic apparently will only use a single wildcard, making *pattern* type wildcard matching not possible.

 

 

 

Can anyone confirm, or point to other options ?

 

 

 

regards,

 

 

 

5 Replies

  • You can check the URI in the request using [HTTP::uri] and use switch to handle multiple patterns:

    
    when HTTP_REQUEST {
       switch -glob [HTTP::uri] {
          "*RefID*" -
          "*TrkNum*" {
              Matched RefID or TrkNum
          }
          default {
              No match
          }
       }
    }
    

    Aaron
  • Also, if the strings you want to check for are in the query string you could change [HTTP::uri] to [HTTP::query] to be more precise.

     

     

    Aaron
  • That's good to hear. I was informed by our datacenter that *wildcard*-pattern-*wildcard* type iRules were just not possible, since only the first wildcard would be read.
  • switch -glob uses the same matching logic as TCL string match so you can definitely use multiple wildcards and character classes:

     

     

    % string match {*2*4*} 123456789

     

    1

     

     

    % string match {*[0-9]*} abc5def

     

    1

     

     

    % string match {*2*5[6-8]*9} 123456789

     

    1

     

     

    Aaron
  • That worked, by the way. Have successfully enabled the listed rules, and PPC links are working correctly now.