Forum Discussion
Rewrite URI in multiple places
Hi all,
Hoping to get some assistance please with the following.
So a request will come into the LTM such as;
https://dev-portal.domain.com.au/bpointcallback/206752391256402?ResponseCode=0&ResponseText=Success&ResultKey=13cfa799-8278-4872-a705-7ed49d516c0b
and we would like it to be changed to;
http://dev-portal5.sub.domain.com.au/apex/f?p=ARPAY:BPOINTRESP:206752391256402:::::?ResponseCode=0&ResponseText=Success&ResultKey=13cfa799-8278-4872-a705-7ed49d516c0b
In summary;
https://dev-portal.domain.com.au/bpointcallback/
changed to;
http://dev-portal5.sub.domain.com.au/apex/f?p=ARPAY:BPOINTRESP:
and we are replacing;
?ResponseCode
to;
:::::?ResponseCode
apart from that everything else remains as is.
Kind Regards,
Hi
If you want to replace one string with another then you could use string map. The code would look something like
when HTTP_REQUEST { log local0. "Before Change: [HTTP::host] - [HTTP::uri]" if {([HTTP::host] eq "dev-portal.domain.com.au") && ([HTTP::uri] starts_with "/bpointcallback/")}{ HTTP::header replace Host "dev-portal5.sub.domain.com.au" HTTP::uri [string map -nocase [list "/bpointcallback/" "/apex/f?p=ARPAY:BPOINTRESP:" "?ResponseCode" ":::::?ResponseCode"] [HTTP::uri]] log local0. "After Change: [HTTP::host] - [HTTP::uri]" } }
- iaineNacreous
Hi
If you want to replace one string with another then you could use string map. The code would look something like
when HTTP_REQUEST { log local0. "Before Change: [HTTP::host] - [HTTP::uri]" if {([HTTP::host] eq "dev-portal.domain.com.au") && ([HTTP::uri] starts_with "/bpointcallback/")}{ HTTP::header replace Host "dev-portal5.sub.domain.com.au" HTTP::uri [string map -nocase [list "/bpointcallback/" "/apex/f?p=ARPAY:BPOINTRESP:" "?ResponseCode" ":::::?ResponseCode"] [HTTP::uri]] log local0. "After Change: [HTTP::host] - [HTTP::uri]" } }
- Stuart_BuckNimbostratus
Thank you very much for that!!!
Just had to redirect it and works perfect ;)
HTTP::respond 301 Location http://[HTTP::host][HTTP::uri]
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