Mar 27, 2026 - For details about updated CVE-2025-53521 (BIG-IP APM vulnerability), refer to K000156741.

Forum Discussion

RoadRunnerA's avatar
RoadRunnerA
Icon for Nimbostratus rankNimbostratus
Feb 07, 2022

iRule to remove any first two segments from the URI

Hi there,

 

I'm trying to have an iRule to remove the first two URI segment, whatever there values are.

 

ex:

original request

www.1234.com/path/to/file.xhtml

modified request

www.1234.com/file.xhtml

where as /path/to/ is changable.

 

any ideas.

 

thnx 

2 Replies

  • xuwen's avatar
    xuwen
    Icon for Cumulonimbus rankCumulonimbus
    when HTTP_REQUEST {
     set uri [HTTP::uri]
     set skip_path_length [expr { 1 + [string length [lrange [split $uri "/"] 1 2]] }]
     HTTP::uri "[string range [HTTP::uri] $skip_path_length end]"
    }

    OR:

    when HTTP_REQUEST {
     set uri [HTTP::uri]
     HTTP::uri "/[join [lrange [split $uri "/"] 3 end] "/"]"
    }

     

     

     

    tcl test example:

    (bin) 79 % set uri /path/to/file.xhtml
    /path/to/file.xhtml
    (bin) 80 % string range $uri [expr { 1 + [string length [lrange [split $uri "/"] 1 2]] }] end
    /file.xhtml
    (bin) 81 %puts "/[join [lrange [split $uri "/"] 3 end] "/"]"
    /file.xhtml

     

  • hi RoadRunnerA, if xuwen's answer was helpful, would you mind accepting the solution? This helps everyone knowing that a solution was reached for the problem being discussed.