For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Curious1's avatar
Curious1
Icon for Cirrus rankCirrus
Nov 29, 2019
Solved

URI Rewrite remove info

How can I remove info from the below URI? Other objects will be called after the numbers so cant just rewrite URI to "/"   hxxp://abc.com/1.2.3.4 : remove any IP address after the /
  • Enes_Afsin_Al's avatar
    Jan 07, 2020

    Hi Curious,

    Can you try this iRule?

    when HTTP_REQUEST {
        if { [string match {/[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*} [HTTP::uri]] } {
            # log local0. "matchedUri: [HTTP::uri]"
            
            set changedUri [string trimleft [HTTP::uri] "/"]
            # log local0. "changedUri: $changedUri"
            
            if { $changedUri contains "/"} {
                set newUri "[string range $changedUri [string first / $changedUri] end]"
            } else {
                set newUri "/"
            }
            # log local0. "newUri: $newUri"
            
            HTTP::redirect "http://[HTTP::host]$newUri"
        }
    }

    You can change regex with better expression. I couldn't find exact expression for the IP match.