Forum Discussion

Bryan_38092's avatar
Bryan_38092
Icon for Nimbostratus rankNimbostratus
Jun 09, 2015

Create iRule to remove everything after a string found in the URI

Looking for some help, trying to create an iRule to remove everything including a string it finds in the URI. For example, http://www.foobar.com/data/12345=rank&format=XYZ and I want to remove the ...
  • nitass_89166's avatar
    Jun 10, 2015

    this is just another example.

     configuration
    
    [root@ve11b:Active:In Sync] config  tmsh list ltm rule qux
    ltm rule qux {
        when HTTP_REQUEST {
      set uri [HTTP::uri]
      if { $uri contains "format=XYZ" } {
        HTTP::uri [string map {"&format=XYZ" "" "format=XYZ&" "" "format=XYZ" ""} $uri]
      }
      log local0. "Before: $uri After: [HTTP::uri]"
    }
    }
    
     /var/log/ltm
    
    [root@ve11b:Active:In Sync] config  tail -f /var/log/ltm
    Jun 10 22:03:00 ve11b info tmm[10343]: Rule /Common/qux : Before: /data/ After: /data/
    Jun 10 22:03:09 ve11b info tmm[10343]: Rule /Common/qux : Before: /data/12345=rank&format=XYZ After: /data/12345=rank
    Jun 10 22:03:17 ve11b info tmm1[10343]: Rule /Common/qux : Before: /data/format=XYZ&12345=rank After: /data/12345=rank
    Jun 10 22:03:27 ve11b info tmm[10343]: Rule /Common/qux : Before: /data/test=abc&format=XYZ&12345=rank After: /data/test=abc&12345=rank