After seeing the logs I can see that the keys as well as the values can be different, so this required a slightly different approach.
This time the iRule will read the query, break it apart into a list and loop through each query, appending the value of each query key to a new URI. Once complete it will add this new, dynamically built URI to the redirect.
I've tested it and it seems to do what's required. Please check and let me know how you get on
when HTTP_REQUEST {
split each query into a list using & as separator
set queryList [split [HTTP::query] "&"]
set newUri "/path/"
set i 0
if { [HTTP::host] equals "www.host.com"} {
if { [HTTP::uri] starts_with "/path/" } {
loop through each query and append value to $newUri
foreach param $queryList {
set query [split [lindex $queryList $i] "="]
set value [URI::query [HTTP::uri] [lindex $query 0]]
append newUri $value /
incr i
}
redirect to new URI after looping has finished
log local0. "new URI is $newUri - redirecting"
HTTP::respond 301 noserver Location "https://[HTTP::host]$newUri"
}
}
}
Lee