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.
use a string replace function, you can find many answers
https://devcentral.f5.com/s/question/0D51T00006i7k6Z/irule-replace-a-part-of-uri
https://devcentral.f5.com/s/articles/irules-101-14-tcl-string-commands-part-2
- jaikumar_f5Nov 30, 2019MVP
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 ?
- boneyardNov 30, 2019MVP
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.
- Curious1Jan 07, 2020Cirrus
Hey, any further help available on this as it has me beat?
The URLs will change in length as there will be different IP's that need to be removed. No pool will be assigned to the VS and the IP shown in the URL will be used to select a target to connect to. The IP in the URL needs to be removed as this URL will be invalid when requesting the resource on the target.
eg1. hxxp://abc.com/10.4.5.100/path/file (remove the IP and keep anything else)
eg2. hxxp://abc.com/10.50.100.200/path/file
Any assistance will be really appreciated.
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