Forum Discussion

lawrence_Wickli's avatar
lawrence_Wickli
Icon for Nimbostratus rankNimbostratus
Jun 27, 2006

Matchng a specific directory.

Hello all,

 

 

I am trying to match a specific directory and redirect apropriately without using regex rules. Here is what I have so far:

 

 

if { [string tolower [HTTP::uri]] starts_with "/about_us" } {

 

 

pool p_http_aboutus

 

 

I need it to ignore case and I need it to be limited to just the first /about_us directory and /about_us/ and not /about_us1 etc.

 

 

I have multiple of these to parse so I am considering a class to help but right now I just need to limit it to exactly the directories I need with out the wildcard on the back side.

 

 

Any recomendation on how I should approach this?

3 Replies

  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    You could use getfield to extract the first directory regardless of trailing slash:
    if { [getfield [string tolower [HTTP::uri]] "/" 2] equals "about_us" } {
      pool p_http_aboutus
    }
    getfield splits the first parameter into fields delimted by the character in the 2nd parameter, and returns the field requested in the 3rd, starting at index 1. Since a URI always starts with a "/", field 1 is blank and field 2 contains the name of the first directory in the URI.

    HTH

    /deb
  • So what I have ended up with is

     

    when HTTP_REQUEST {

     

     

    switch [getfield [string tolower [HTTP::uri]] "/" 2] {

     

    about_us { pool p_http_about_us }

     

    common { pool p_http_common}

     

    content { pool p_http_content}

     

    default { pool p_http_default}

     

    }

     

    }

     

     

    is this rule as fast as I can get it or is there another approach?