Forum Discussion

Nicholas_Teo's avatar
Nicholas_Teo
Icon for Nimbostratus rankNimbostratus
Sep 20, 2018

iRule equals not matching similar keys in datagroup

Hi!

So we have an iRule which matches the URI against a datagroup via equals, nothing out of the ordinary:

when HTTP_REQUEST {
    set matchedEquals [class match -value [string tolower [HTTP::uri]] equals dg_list]

    if {$matchedEquals ne ""} {
        HTTP::respond 301 Location "$matchedEquals"
        unset matchedEquals
    }
}

We recently had a case where there are 2 similar URI's in the datagroup:

  1. /api :=
  2. /api/demo :=

We find that the iRule is able to match /api, but is unable to match for /api/demo. From what I understand, the equals operator would match the longest key, so not exactly sure why it is failing to match.

Any help would be much appreciated. Thanks in advance!

  • Hi Nicholas,

     

    strange behaviour can you replace equals by "=="

     

    and log URI:

     

    log local0. "URI: [string tolower [HTTP::uri]]" to be sure that you math "/api/demo"

     

    regards