Forum Discussion

F5866's avatar
F5866
Icon for Nimbostratus rankNimbostratus
Apr 09, 2019

irule query on uri match

Hi,

 

Have a question on following irule.

 

when HTTP_REQUEST { log local0. "Host header is [HTTP::host]" switch [string tolower [HTTP::host]] { "example1.com" { log local0. "matched example1.com" pool number1 } "example2.com" { log local0. "example2.com" pool number2 } } }

 

Wanted to know whether this irule will match to exact URL http://example1.com and http://example2.com or it can also match http://www.example1.com and http://www.example2.com

 

  • You can need to use

    -glob
    type matching so that you can match on and example.com. "*example1.com" essentially means - a host header that ends with "example1.com"

    when HTTP_REQUEST { 
        log local0. "Host header is [HTTP::host]" 
        switch -glob [string tolower [HTTP::host]] { 
            "*example1.com" { 
                log local0. "matched example1.com" 
                pool number1 
            } 
            "*example2.com" { 
                log local0. "example2.com" 
                pool number2 
            } 
        } 
    }