I know how to redirect from:
http://domain.com to https://www.domain.com
and
http://www.domain.com to https://www.domain.com
but not how to redirect from:
https://domain.com to https://www.domain.com
I am using on the virtual server for port 80 : (this works fine)
RedirectMatch 301 ^/$ https://www.domain.com
RedirectMatch 301 ^(.*)$ https://www.domain.com
RedirectMatch 301 ^http://domain.com/$ https://www.domain.com
I tried using on the virtual server port 443, but it does not work.
Redirectmatch 301 ^https://domain.com/ https://www.domain.com
Under Type, select the Permanent (301) option. On https?://, enter the domain you want to redirect. Leave the path section (/) empty. In the Redirects to field, type in your website's www URL.
You will need to have a valid SSL certificate for https://www.example.com as the hostname is encrypted inside the HTTP header so your server won't know to redirect until it's decrypted. After that it should redirect as it would a normal HTTP request.
You would need to have a certificate that matches domain.com, as well as your standard www.domain.com certificate, since you can't redirect until after an SSL channel has been established.
Most people wouldn't think it was worth the expense of obtaining two certificates for each domain, just to achieve a redirect. A Wildcard certificate wouldn't help here (I believe), since I think all domains covered by a wildcard cert have to be at the same level (e.g. *.domain.com would be valid for www.domain.com and www2.domain.com, but not for just domain.com)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With