Ubuntu 14.x 上带有虚拟主机的 Apache2 SSL 配置

Apache2 SSL Configuration with Virtual Hosts on Ubuntu 14.x

我希望只有 https 流量。我希望所有这些都被驱动到 https://example.com and https://www.example.com

目前这是有效的和无效的:

https://www.example.com - 好的! http://www.example.com - 出于某种原因显示我的 webroot 中的文件列表 https://example.com - 无法访问此站点/example.com 拒绝连接。 http://example.com - example.com 页面不工作。 example.com 没有发送任何数据。

我正在使用 Ubuntu 14(可信),这是我当前启用的虚拟主机配置:

<IfModule mod_ssl.c>
       <VirtualHost xxx.xxx.xxx.xxx:443>
               ServerAdmin info@example.com
               ServerName www.example.com:443
               ServerAlias example.com:443

               DocumentRoot /var/www/example.com/public_html

              SSLEngine on
              SSLCertificateFile      /etc/ssl/certs/ssl-cert-snakeoil.pem
              SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

              <FilesMatch "\.(cgi|shtml|phtml|php)$">
                              SSLOptions +StdEnvVars
              </FilesMatch>

              <Directory /usr/lib/cgi-bin>
                              SSLOptions +StdEnvVars
             </Directory>
             BrowserMatch "MSIE [2-6]" \
                             nokeepalive ssl-unclean-shutdown \
                             downgrade-1.0 force-response-1.0
             # MSIE 7 and newer should be able to use keepalive
             BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
     </VirtualHost>
</IfModule>

任何帮助都非常感谢!

您尝试过永久重定向吗? https://wiki.apache.org/httpd/RedirectSSL