简体   繁体   中英

Redirecting from https://example.com to https://www.example.com in htacess

I have a website with the ssl for www.example.com. I have set up a htaccess redirect which redirects the user from http://example.com => http://www.example.com. If I enter https://www.example.com then it works. But if I enter https://example.com then it gives me a ssl error.

How do I redirect https://example.com to https://www.example.com without showing the ssl error?

I use the following code in my htaccess to redirect.

RewriteCond %{HTTP_HOST} !^www\.

RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

This is related to your SSL setup, probably its not set for (*.domain.com) if so (www.domain.com) doesn't issues any error.

www.domain.com != domain.com

Because www is subdomain, that redirected to ( domain.com ), then, you need to enable SSL for ( *.domain.com ) or just for ( www.domain.com ) as suggested by @Jack

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