Reputation: 4152
Is there a way to redirect:
To:
I have tried some solutions offered but they only work if the user enters www.doamin.com in the address field, as soon as they enter https://www.domain.com it does not work. I get a "Your connection is not private" error message in Chrome and the https is crossed out because our SSL is registered for domain.com NOT www.domain.com.
I've tried the following in the htaccess but it doesn't work if a user enters https://www.domain.com only if they enter www.domain.com:
# Remove www from the URL.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
I've also tried the following in my virtual host entry, but the result is the same as the above:
Redirect permanent / https://domain.com/
Thanks for any help.
Upvotes: 2
Views: 900
Reputation: 9343
To Clarify Andrews comment. When connecting to a HTTPS service, the encryption is negotiated before the domain name is passed to the server.
If you certificate is for domain.com, then any visitors will always get the insecure warning message at the SSL negotiation stage before the domain is sent to the server and redirected by your rewrite rules.
The solution is to get a SAN (Subject Alternative Name) certificate that covers both www.domain.com and domain.com.
Upvotes: 1