Forum Discussion

Ed_Lane_26850's avatar
Ed_Lane_26850
Icon for Nimbostratus rankNimbostratus
Jun 24, 2011

irule redirect

I am having trouble with creating an irule that will redirect when url http://www.offer.sportography.com is received and redirect it to http://offer.sportography.com dropping the www from the url.

 

 

thanks much, Ed Lane

 

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    All you'd need is:

    
    when HTTP_REQUEST {
      if {[HTTP::host] equals "www.offer.sportography.com"} {
        HTTP::redirect "http://[string trimleft [HTTP::host] 'w.']"
      }
    }
    

    This will strip any "w" or "." characters from the left of the string. It basically eats all characters found within the single quotes, w. in this case, until it gets to the first character that isn't one of those two values.

    Colin
  • string trimleft is a novel solution Colin. And it seems to perform as well as a string range command. Nice work :)

     

     

    Aaron