Is there a way to access 'mod_rewrite' before 'mod_ssl'?
Solution 1:
No, HTTPS is HTTP over TLS/SSL (see RFC 2818), which first establishes the SSL/TLS connection before any HTTP traffic is sent. mod_rewrite
will always apply after the SSL/TLS connection is established.
Not doing so would actually be a security issue, since an attacker could rewrite and redirect the client before the certificate has been verified. Even if the TLS upgrade was within HTTP (RFC 2817, which is virtually never used/supported and is not https
), you would still want the redirection to come from a trusted entity.
The way around this is to use a certificate with multiple Subject Alternative Name (SAN) DNS entries, one for each host name, or multiple certificates (in which case you may need one IP address per certificate too, unless you're willing to use Server Name Indication).
Solution 2:
No, there is no way to do this. Consider getting a SAN certificate that includes both names. If you get 2 certs, you will need 2 IP addresses.