Forum Discussion

Puneet_SETH's avatar
Puneet_SETH
Ret. Employee
Dec 16, 2019

URI Rewrite when sending the packet to Backend

Hi All,

 

I'm working on this requirement to rewrite the URI path in the HTTP Request, just the URI path and not the query portion.

 

E.g.

Incoming request to

http://1.1.1.1/test/abc?param=1234567890

 

should be translate to when sending to backend.

 

https://2.2.2.2/test/abc1?param=1234567890

 

I've tried few iterations but none have worked for me so far.

 

Sample1

when HTTP_REQUEST {

if { [HTTP::uri] starts_with "/abc1?/" } {

HTTP::uri [string map {"/abc1?/" "/abc2?/"} [HTTP::uri]]

}

}

 

Sample2

when HTTP_REQUEST {

   if {[HTTP::uri] contains "test/abc?param=" } {

       set newURI [string map {"test/abc?param=" ""} [HTTP::uri]]

       HTTP::uri /test/abc1?param=

       }

2 Replies