how to redirect https:// to https://www

0

Issue

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

Solution

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)

Answered By – Damien_The_Unbeliever

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More