Redirecting specific URL to another URL either via http or https

Using iRule, I am trying to redirect 2 old URL to 2 new URL via http and 1 old to new URL via https… such as following: http://www.old1.com to http://new1.com, http://www.old2.com to http://new2.com, and http://www.old3.com to https://new3.com. Following is current iRule, I am using.

when HTTP_REQUEST {  

     if { [string tolower [HTTP::host]] equals "www.site1.com" } {  
          HTTP::respond 301 Location "http://new1.com[HTTP::uri]"
     }  

     if { [string tolower [HTTP::host]] equals "www.site2.com" } {
          HTTP::respond 301 Location "http://new2.com[HTTP::uri]"
     }  

     if { [string tolower [HTTP::host]] equals "www.site3.com" } {
          HTTP::respond 301 Location "https://new3.com[HTTP::uri]"
     }  

}

Perhaps a slight optimization:

when HTTP_REQUEST {
    if { [string tolower [HTTP::host]] equals "www.site1.com" } {
        HTTP::respond 301 Location "http://new1.com[HTTP::uri]"
    } elseif { [string tolower [HTTP::host]] equals "www.site2.com" } {
        HTTP::respond 301 Location "http://new2.com[HTTP::uri]"
    } elseif { [string tolower [HTTP::host]] equals "www.site3.com" } {
        HTTP::respond 301 Location "https://new3.com[HTTP::uri]"
    }
}

This should only redirect the specified Hosts and allow the rest to pass through. You could also use a switch statement:

when HTTP_REQUEST {
    switch [string tolower [HTTP::host]] {
        "www.site1.com" {
            HTTP::respond 301 Location "http://new1.com[HTTP::uri]"
        }
        "www.site2.com" {
            HTTP::respond 301 Location "http://new2.com[HTTP::uri]"
        }
        "www.site3.com" {
            HTTP::respond 301 Location "https://new3.com[HTTP::uri]"
        }
    }
}

Or you could use an HTTP class (11.3 and below) or a policy (11.4 and above).