Forum Discussion

jwitko's avatar
jwitko
Icon for Nimbostratus rankNimbostratus
Jun 05, 2013

Can I use a wildcard inside a HTTP::host contains conditional?

I have the following iRule:

 

 

when HTTP_REQUEST {

 

if {[HTTP::host] contains "example.domain.com" } {

 

switch -glob [HTTP::uri] {

 

"*example=e*" { pool examplee_http }

 

"*example=f*" { pool examplef_http }

 

"*example=g*" { pool exampleg_http }

 

default { pool examplee_http }

 

}

 

}

 

}

 

 

Is it possible to insert a wildcard into the 'contains' field so I can make this active on all versions of example*.domain.com? For instance is the following acceptable (modification in line 2):

 

 

when HTTP_REQUEST {

 

if {[HTTP::host] contains "example*.domain.com" } {

 

switch -glob [HTTP::uri] {

 

"*example=e*" { pool examplee_http }

 

"*example=f*" { pool examplef_http }

 

"*example=g*" { pool exampleg_http }

 

default { pool examplee_http }

 

}

 

}

 

}

 

 

 

Thanks!

 

 

-jwitko

 

1 Reply

  • You cannot use wildcards with the contains operator, but you could use an equivalent string function:

    
    when HTTP_REQUEST {
        if { [string match "example*.domain.com" [string tolower [HTTP::host]]] } {
            switch -glob [string tolower [HTTP::uri]] {
                "/example=e*" { pool local-pool }
                "/example=f*" { pool local-pool }
                "/example=g*" { pool local-pool }
                default { pool local-pool }
            }
        }
    }