Forum Discussion

JeffM's avatar
JeffM
Icon for Nimbostratus rankNimbostratus
Apr 29, 2014

iRule to include / but not /*

A request has come in to create an iRule to filter traffic for /, /common, /etc, and /index.html to goto pool_A and all other content to goto pool_B. The issue I am running into is that once I include / it treats it as /*. Is there a way to include / with out it seeing it as / * ?

 

3 Replies

  • Try this:

    when HTTP_REQUEST {
        switch -glob [string tolower [HTTP::uri]] {
            "/" -
            "/common*" -
            "/etc*" -
            "/index.html*" { pool pool_A }
            default { pool pool_B }
        }
    }
    

    The -glob switch allows you to pattern match around the specified URIs. However, specifying the "/" URI without the * wildcard means exact match.

  • Can you call a -glob for / and then have an else statment for the rest of the paths to be managed by a Data Group List. This would be safter for on going updates/maintenance.

    Perhaps something like this might be better:

    when HTTP_REQUEST {
        if { ( [HTTP::uri] equals "/" ) or ( [class match [string tolower [HTTP::uri]] starts_with my_uri_dg] ) } {
            pool pool_A
        } else {
            pool pool_B
        }
    }