trying to redirect one https url to another

We have SSL cert for one domain1 but not for domain2. Our links are all relative and a link works just fine. However generates a SSL cert error as expected.

In order to get around that without having to hard code the contactus links on domain2 to domain1, i am trying to write an iRule. I tried the one below but the page still gives me the SSL cert error and then redirects to domain1 instead. Any ideas?

when HTTP_REQUEST {
    if { ([HTTP::host] contains "domain2") and (([HTTP::uri] contains "view=contactus") or ([HTTP::uri] contains "view=emailto"))
        }
    { HTTP::respond 301 Location "https://domain1[HTTP::uri]"
    }
}

The TLS negotiation occurs before any higher layer messages are exchanged. Even if you configured the web server to respond with a redirect, you would still get the cert warning. This is by design. Otherwise, a man-in-the-middle could inject a redirect (or really, any response) without the client knowing that it was not coming from the intended endpoint.

thanks for the quick response.