我的网站有一个SSL证书(例如url: https : //subdomain.example.com )。 在Apache下,为端口80和端口443设置。因此,在以下configuration下,任何访问http://subdomain.example.com的人都将被发送到https://subdomain.example.com 。 但是,从Internet Explorer访问,redirect不会发生。 相反,http访问得到一个“Internet Explorer无法显示网页”。 与客户端解决scheme列表尝试。
有关如何修复configuration的任何想法,所以IE访问具有与其他浏览器相同的行为(即自动发送http到https)?
NameVirtualHost *:443 <VirtualHost *:80> DocumentRoot /var/www/somewebroot ServerName subdomain.example.com </VirtualHost> <VirtualHost *:443> DocumentRoot /var/www/somewebroot ServerName subdomain.example.com # SSL CERTS HERE </VirtualHost>
*testingIE8,IE9testing版
把这个代码放在HTTP虚拟主机的定义中应该这样做。
RewriteCond%{HTTPS}!= on [NC]
RewriteRule ^ /(。*)https://subdomain.example.com [R = 301,L]
如果您正在testing更改,则可能会出现IE问题,除非您closures所有IE窗口并重新启动。 IE可以积极地使用它的caching。
编辑:您需要确保mod_rewrite已启用。 命令是a2enmod rewrite 。 它会告诉你,如果模块已经启用。 如果没有,则需要在启用模块后closures并重新启动服务器。
将上面的行添加到您的虚拟主机定义中,并使用apache2ctl graceful重新加载修改后的configuration。 Apache文档具有重写的细节。
您应该在您的访问日志中看到redirect为301状态请求,然后在HTTPS连接上显示200或304状态。 显示的url应该更改为新的位置。
以扩展日志格式logging端口有助于查看发生了哪些连接。 或者,为每个虚拟服务器使用单独的日志。