简体   繁体   中英

SSL Error: how to redirect https://www.domain.com to http://domain.com via .htaccess to avoid SSL error

I have a problem with our website when going to https :// www. domain. com a "This Connection is Untrusted" warning appears, and pages can't be found if https: // www.domain.com / nameofpage/s is typed at browsers. But all is fine if it is https:// domain.com/ nameofpage/s

Our certificate details:
Purchased at: http://www.ssls.com/
Common Name is: domain.com

This is what my .htaccess look like:

<IfModule mod_rewrite.c>
RewriteEngine on
Options +FollowSymLinks
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1

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

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} (auth|register|report|bootstrap)
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301]

RewriteCond %{HTTPS} on
RewriteCond %{HTTPS_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ https://domain.com/$1 [R=301,L]

</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>

Because domain.com does not match www.domain.com it will not do the SSL connection. And because the HTTP redirect can only be done once the SSL connection is established it will not be able to do the redirect. Your only chance is do get a certificate which includes domain.com and www.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