我正在一个只拥有domain.com的SSL证书的网站上工作。我正试图删除www。并重定向到domain.com。这我工作得很好。强制HTTPS和无需接收证书错误带WWW
我也想强制所有页面上的HTTPS,这工作正常,如果www。没有输入。
当我们的URL为https://www.domain.com时出现错误。
我可以看到它重写为https://domain.com但我得到一个证书错误,我必须接受或拒绝。
有没有办法解决这个问题而不购买其他证书?
下面是我尝试过的许多规则组合中的两种(其中很多来自其他SO答案)。
1.
RewriteCond %{HTTP_HOST} ^(www\.)(.+) [OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?(.+)
RewriteRule^https://%2%{REQUEST_URI} [R=301,L]
2.
RewriteCond %{HTTPS} =on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule^https://%1%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule^http://%1%{REQUEST_URI} [R=301,L]
RewriteCond %{SERVER_PORT} !^443
RewriteRule^https://domain.com%{REQUEST_URI} [R=301,L]
的[重定向到“WWW”可能重复之前ssl要求](http://stackoverflow.com/questions/10929534/redirect-to-www-before-ssl-requirement) – Bruno 2012-08-09 22:27:13
或这些:http://stackoverflow.com/q/11640198/372643 http:// stackoverflow.com/q/10442858/372643 – Bruno 2012-08-09 22:31:44