Forum Discussion
Replace URI (wildcard) with null
Ive been searching around the last couple days and haven't been able to find a good solution to this yet. I tried to accomplish it with sting map so I wouldn't have to use regex but it doesn't seem to support wildcards. I am new to writing an irule in regex and want to see if they community could assist with this rule and had a better idea how to write it.
My iRule is as follows:
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] contains "\/@v=" } {
set uri [HTTP::uri]
regsub [\/@v=.*@" $uri "" url2]
HTTP::uri $url2
}
}
When web requests come in as mydomain.com/foo/@v=-1654270807@/bar/123/foo123/pic.jpg I need to strip out /@v=-0123456789@ so my webserver can handle the request. What I am finding difficult to solve is the number 0123456789 can be any number. Any ideas on how I could accomplish this? I would prefer not to use redirects also.
2 Replies
- Kevin_Stewart
Employee
There's a million ways to manipulate strings in TCL/iRules. Here's one example that should meet your requirements.when HTTP_REQUEST { if { [string tolower [HTTP::uri]] contains "/@v=" } { extract the dynamic number data from the URI set filter [findstr [string tolower [HTTP::uri]] "/@v=" 4 "@"] use a string map to remove the number data set newuri [string map "/@v=$filter@/ /" [string tolower [HTTP::uri]]] HTTP::uri $newuri } } - NorCalAdam_6796
Nimbostratus
Thank you very much! That worked perfect!
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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