irule combination for response and redirect

i have an irule on HTTP vs redirecting HTTP to HTTPS which works fine for me. For this redirects the response from the F5 is a 302 i want to change this to a 301 and i want to do this with one irule. The redirect applies to all url and the response code change applies to a specific url.

How about checking this link:

http to https

The example in this link is as follows:

when HTTP_REQUEST {
  HTTP::respond 301 Location "https://[getfield [HTTP::host] : 1][HTTP::uri]"
}