Forum Discussion
Bryan_38092
Jun 09, 2015Nimbostratus
Create iRule to remove everything after a string found in the URI
Looking for some help, trying to create an iRule to remove everything including a string it finds in the URI. For example, http://www.foobar.com/data/12345=rank&format=XYZ and I want to remove the ...
- Jun 10, 2015
this is just another example.
configuration [root@ve11b:Active:In Sync] config tmsh list ltm rule qux ltm rule qux { when HTTP_REQUEST { set uri [HTTP::uri] if { $uri contains "format=XYZ" } { HTTP::uri [string map {"&format=XYZ" "" "format=XYZ&" "" "format=XYZ" ""} $uri] } log local0. "Before: $uri After: [HTTP::uri]" } } /var/log/ltm [root@ve11b:Active:In Sync] config tail -f /var/log/ltm Jun 10 22:03:00 ve11b info tmm[10343]: Rule /Common/qux : Before: /data/ After: /data/ Jun 10 22:03:09 ve11b info tmm[10343]: Rule /Common/qux : Before: /data/12345=rank&format=XYZ After: /data/12345=rank Jun 10 22:03:17 ve11b info tmm1[10343]: Rule /Common/qux : Before: /data/format=XYZ&12345=rank After: /data/12345=rank Jun 10 22:03:27 ve11b info tmm[10343]: Rule /Common/qux : Before: /data/test=abc&format=XYZ&12345=rank After: /data/test=abc&12345=rank
cjunior
Jun 09, 2015Nacreous
Hi Bryan,
In my example, I considered that the parameter may be in the beginning, case insensitive And I think that the pool statement is useless in that scenario.when HTTP_REQUEST {
if { [string tolower [HTTP::query]] starts_with "format=xyz" } {
HTTP::uri ""
} elseif { [string tolower [HTTP::query]] contains "&format=xyz" } {
HTTP::uri [string range [HTTP::uri] 0 [expr "[string first "&format=xyz" [string tolower [HTTP::uri]]]-1"]]
}
log local0. "[HTTP::uri]"
}
I hope it helps you. [ ]
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