Forum Discussion
URI Rewrite remove info
- 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.
string tcl can look for exact strings, it doesn't act as a regex. The Op is asking for any IP address, not a particular IP address. Would this be still possible ?
if you first get the ip address, split on / perhaps you can string replace against that i guess.
also with a other string tricks you can make this work. for example look for first slash, remove (trim) upto that.
and of course you could use regexp as you point out, although the performance impact of that is higher.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com