Forum Discussion
Eric_Frankenfie
Oct 07, 2013Nimbostratus
URI Rewrite
I have a developer who is working a new version of an application and they would like to perform the following URI rewrite on the F5 so they don't have to deploy duplicate code to 100+ virtual direct...
Oct 07, 2013
Assuming you know the vendor name variable, you can do something like this:
set vendor "vendorName"; assign from header or some other input
if { [HTTP::uri] starts_with "/${vendor}?" } {
HTTP::uri [string map [list "/${vendor}?" "?${vendor}&"] [HTTP::uri]]
}
If you want to look for all patterns and of "/?" and replace it, you can do so with something like this
if { ([HTTP::uri] starts_with "/") && ([HTTP::uri] contains "?") } {
Find the index of the "?" character
set idx [string first "?" [HTTP::uri]]
extract the string from index 1 up to the character before the "?"
set site [string range [HTTP::uri] 1 [expr $idx - 1]]
Modify the URI with the string replacement.
HTTP::uri [string map [list "/${site}?" "?${site}&"] [HTTP::uri]]
}
Keep in mind that this isn't bulletproof. So make sure the logic fits for all of your URLs.
-Joe
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