Forum Discussion

Stuart_Buck's avatar
Stuart_Buck
Icon for Nimbostratus rankNimbostratus
Oct 15, 2019
Solved

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&Respon...
  • iaine's avatar
    Oct 15, 2019

    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]"
    }
    }