MustphaBassim First I would like to note that the server really should be corrected to provide the appropriate redirect instead of solving for this on the F5. If you wanted to test this yourself the following iRule might do what you need it to.
when HTTP_REQUEST priority 500 {
set HOST [HTTP::host]
}
when HTTP_RESPONSE priority 500 {
if { ([HTTP::status] starts_with "3") and ([HTTP::header Location] contains ${HOST}) } {
HTTP::header replace Location [string map {http: https:} [HTTP::header value Location]]
}
}