Forum Discussion
Curious1
Nov 29, 2019Cirrus
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 /
- 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.
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.
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects