Dynamic String 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://example1.com/administration/data/value
2nd URL = http://example2.com/finance/data/value
when HTTP_REQUEST {
if {[string tolower [HTTP::host]] equals "https://example1.com"}{
if {[string tolower [HTTP::uri]] contains "/administration/data/"}{
HTTP::respond 302 noserver Location "http://example2.com[string map -nocase {"//finance/data/"} [HTTP::uri]]"
}
}
}
===================================================================
when HTTP_REQUEST {
set uri [HTTP::uri]
if { [HTTP::uri] contains "/administration/data/" } {
log local0. "Original URI: $uri"
HTTP::uri [string range [HTTP::uri] 400 end]
log local0. "Search Query: [HTTP::uri]"
HTTP::uri /finance/data/[HTTP::uri]
log local0. "New URI: [HTTP::uri]"
HTTP::redirect "http://example2.com[HTTP::uri]"
}
elseif { $uri starts_with "/administration/data/" } {
log local0. "Original URI: $uri"
HTTP::uri [string range [HTTP::uri] 400 end]
log local0. "Search Query: [HTTP::uri]"
HTTP::uri /finance/data/[HTTP::uri]
log local0. "New URI: [HTTP::uri]"
HTTP::redirect "http://example2.com[HTTP::uri]"
}
}
I have used these 2 scripts, still got errors, any suggestions to fix this problem?