I'm just learning iRules myself but will try to help. There should be a pre-installed redirect Irule on the LTM. I found one named "_sys_https_redirect". Looks like this.
# Copyright 2003-2006, 2012-2013, 2016, 2019. F5 Networks, Inc. See End User License Agreement ("EULA")
# for license terms. Notwithstanding anything to the contrary in the EULA,
# Licensee may copy and modify this software product for its internal business
# purposes. Further, Licensee may upload, publish and distribute the modified
# version of the software product on devcentral.f5.com.
#
when HTTP_REQUEST {
HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
}
Below is one of my companies redirects.
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] equals "????.com" } {
HTTP::respond 301 Location "https://???.com[HTTP::uri]"
}
}
Hope this helps.