Forum Discussion
farache_28983
Sep 05, 2012Nimbostratus
Rewrite to URL and strip part of the URI
Hi guys,
Basically i need to do this.. been testing different scenarios with HTTP_request and HTTP_RESPONSE but no luck.
When a url comes through from this domain, we would like to ...
Michael_Yates
Sep 10, 2012Nimbostratus
Hi farche,
You are setting the value of the $uri variable to the value in the brakets: string map -nocase {"/v1" "" "/v2" " "}
It is then appending the value to the end of your HTTP::host value. It appears like it is appending it to the HTTP::host value but it really isn't.
Change your set value to this and it should clear your problem:
set uri [HTTP::uri [string map {"/v1" "" "/v2" ""} [HTTP::uri]]]
So the entire iRule should look like this:
when HTTP_REQUEST {
if { ( [string tolower [HTTP::uri]] contains "/v1" ) or ( [string tolower [HTTP::uri]] contains "/v2" ) } {
set uri [HTTP::uri [string map {"/v1" "" "/v2" ""} [HTTP::uri]]]
HTTP::redirect "http://[HTTP::host]$uri"
}
}
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