简体   繁体   中英

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

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

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 (eg *.domain.com would be valid for www.domain.com and www2.domain.com, but not for just domain.com)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM