Need some help with a redirect

I need to do the folowing 301 redirects:

from to

and

from to

was trying with [HTTP::query [HTTP::uri]] but wasn’t capable to achieve that. If anyone can help me, please. thanks in advance

you can try this:

when HTTP_REQUEST {
  if {[HTTP::host] equals "www.host.com" && [HTTP::path] equals "/path1/path2.jsp"} {
    HTTP::respond 301 Location /path3/[URI::query [HTTP::uri] query1]/[URI::query [HTTP::uri] query2][expr {[set var1 [URI::query [HTTP::uri] var1]] ne "" ? "/?var1=${var1}" : "" }]
  }
}