Dynamic Value iRule
Hi everyone,
From past days, I have been struggling an iRule that forward dynamic string from 1st URL to 2nd URL. For example
1st URL = https://example.com/uat/data/value
2nd URL = http://192.168.1.1:8080/test/controller/ticket/ticket.jsp?data=value
Condition: content of "value" variable always updating, for example: today value = 3333 and tomorrow gonna changes to 4444
when HTTP_REQUEST {
if {[string tolower [HTTP::host]] equals "https://example.com"}{
if {[string tolower [HTTP::uri]] contains "/uat/data"}{
HTTP::respond 302 noserver Location "http://192.168.1.1:8080[string map -nocase {"/test/controller/ticket/ticket.jsp?data="} [HTTP::uri]]"
}
}
}
===================================================================
when HTTP_REQUEST {
set uri [HTTP::uri]
if { [HTTP::uri] contains "/uat/data" } {
log local0. "Original URI: $uri"
HTTP::uri [string range [HTTP::uri] 400 end]
log local0. "Search Query: [HTTP::uri]"
HTTP::uri /test/controller/ticket/ticket.jsp?data=[HTTP::uri]
log local0. "New URI: [HTTP::uri]"
HTTP::redirect "http://192.168.1.1:8080[HTTP::uri]"
}
elseif { $uri starts_with "/uat/data" } {
log local0. "Original URI: $uri"
HTTP::uri [string range [HTTP::uri] 400 end]
log local0. "Search Query: [HTTP::uri]"
HTTP::uri /test/controller/ticket/ticket.jsp?data=[HTTP::uri]
log local0. "New URI: [HTTP::uri]"
HTTP::redirect "http://192.168.1.1:8080[HTTP::uri]"
}
}
I have used these 2 scripts, still got errors, any suggestions to fix this problem?