Forum Discussion

dexter_22020's avatar
dexter_22020
Icon for Nimbostratus rankNimbostratus
Apr 09, 2009

url rewrite with class

Hi,

 

 

Newbie on irules here, need help.

 

 

class file contains:

 

 

/test http://domain.com/main.html

 

/foo http://domain.com/foo.html

 

...

 

...

 

and so on..

 

 

I need an irule that will rewrite anything that starts with /test, /foo, etc.. (left column) to what's equivalent on the right column.

 

 

I tried this but I have no idea what's next...

 

 

when HTTP_REQUEST {

 

if { [matchclass [string tolower [HTTP::uri]] starts_with $::test_class] {don't know}

 

}

 

 

 

Thanks for any info.

7 Replies

  • yes, so anything that starts with the pattern on the left column of the data group will be rewritten to the corresponding right column.

     

     

  • I think he's more looking for the findclass functionality Click here. Stream profile could only take care of one of these at a time.

     

     

    Denny
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    You don't need the starts_with operator inside findclass to make this work. Just populate the class like this:

    test /main.html

    foo /foo.html

    Then in your iRule grab the first portion of the URI before doing the comparison.

    So something like:

     
     when HTTP_REQUEST { 
        Grab the portion of the URI after the first / and before the second / 
       set part [getfield [string tolower [HTTP::uri]] "/" 2] 
       set newURI [findclass $part $::yourClass " "] 
       if { $newURI ne "" } { 
         HTTP::uri $newURI 
       } 
     }  
     

    Colin