Forum Discussion
Dec 08, 2015
HTTP redirect with different URIs
Hi,
I have a request to redirect traffic from http://www.abc.com/sites/pmo to http://www.xyz.com/is/pmo. The customer wants all deep links past pmo to work. I tried the below irule, but it is not...
Stanislas_Piro2
Cumulonimbus
Dec 09, 2015Kai, You're right. the "&" must be replaced by "?" in the irule...
For the "string range" vs "string map", I'm no sure is it better to use string range. I checked performance of tcl code with tclsh:
-- Provisioning of variables:
% set uri "/sites/pmo?test=toto&foo=bar"
/sites/pmo?test=toto&foo=bar
% set path /sites/pmo
/sites/pmo
% set query "test=toto&foo=bar"
test=toto&foo=bar-- Test of code:
% set new_uri "http://www.xyz.com/is[string range $uri 6 end]"
http://www.xyz.com/is/pmo?test=toto&foo=bar
% set new_uri "http://www.xyz.com[string map {/sites/pmo /is/pmo} $path]?$query"
http://www.xyz.com/is/pmo?test=toto&foo=bar-- Performance of string range:
% time { set new_uri "http://www.xyz.com/is[string range $uri 6 end]"} 10000
2.9012927 microseconds per iteration
% time { set new_uri "http://www.xyz.com/is[string range $uri 6 end]"} 10000
2.9444715 microseconds per iteration-- Performance of string map:
% time {set new_uri "http://www.xyz.com[string map {/sites/pmo /is/pmo} $path]?$query"} 10000
2.8971892 microseconds per iteration
% time {set new_uri "http://www.xyz.com[string map {/sites/pmo /is/pmo} $path]?$query"} 10000
2.9607483 microseconds per iterationBut I agree that your code does not add a "?" if there is no query string.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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