Forum Discussion

Tom_Lauwereins_'s avatar
Tom_Lauwereins_
Icon for Nimbostratus rankNimbostratus
Jun 15, 2011

Redirect based on URI

Hi,

 

 

I try to implement a simple iRule.

 

Based on URI, traffic has to be redirected to different pools.

 

 

 

when HTTP_REQUEST {

 

if {[matchclass [HTTP::uri] starts_with "/ws/"]}{

 

log local0. "1. Client [IP::client_addr]: client requested [HTTP::host][HTTP::uri]"

 

pool pool_A

 

}

 

else {

 

log local0. "2. Client [IP::client_addr]: client requested [HTTP::host][HTTP::uri]"

 

pool pool_B

 

}

 

}

 

 

 

 

 

 

But I get the error:

 

 

 

- Invalid matchclass operands - no class or list type found, lhs: string, rhs: /ws/ (line 1) invoked from within "matchclass [HTTP::uri] starts_with "/ws/""

 

 

 

 

 

 

Any suggestions?

 

 

 

Tom

 

  • I have found the solution already

     

    Not using "matchclass" solves the problem

     

     

    when HTTP_REQUEST {

     

    if {[HTTP::uri] starts_with "/ws/"}{

     

    log local0. "1. Client [IP::client_addr]: client requested [HTTP::host][HTTP::uri]"

     

    pool pool_A

     

    }

     

    else {

     

    log local0. "2. Client [IP::client_addr]: client requested [HTTP::host][HTTP::uri]"

     

    pool pool_B

     

    }

     

    }
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    The matchclass command is designed to work with data groups rather than directly with strings like "/ws/". For more about the matchclass command you can look here : Click Here.

     

     

    Your logic looks fine as is, though.

     

     

    Colin