我的配置是:

Listen 443 http
NameVirtualHost *:80
NameVirtualHost *:443
ServerName *:80

<VirtualHost *:80> 
  [some non-ssl stuff]
  ServerName account.example.com
</VirtualHost>

<VirtualHost *:443> 
  [some non-ssl stuff(directory, docroot)] 
  ServerName account.example.com
  SSLEngine on
  SSLCertificateFile /Users/myusername/certs/server.crt
  SSLCertificateKeyFile /Users/myusername/certs/server.key
</VirtualHost>

因此,我无法访问网站的HTTP版本,但是SSL版本正常工作。我想通过mod_rewrite使用VHOSTS,HTTP(80)和HTTP(443)(443)将HTTP重写为HTTPS URL。

uname -a
Linux 3.4.62-53.42.amzn1.x86_64 GNU/Linux

httpd -v
Server version: Apache/2.2.25 (Unix)

请帮助了解我做错了什么。

有帮助吗?

解决方案

因此,我现在的配置是:

Listen 443 http
Listen 80
NameVirtualHost *:80
NameVirtualHost *:443
ServerName *:80

<VirtualHost *:443> 
  [some non-ssl stuff(directory, docroot)] 
  ServerName account.example.com
  SSLEngine on
  SSLCertificateFile /Users/myusername/certs/server.crt
  SSLCertificateKeyFile /Users/myusername/certs/server.key
</VirtualHost>

<VirtualHost *:80>
  SSLEngine off
  [other stuff like docroot]
</VirtualHost>

不确定 SSLEngine off, ,但现在起作用。因此,我将重写规则从HTTP重定向到HTTP VHOST的.HTACCESS文件中的HTTP:

#Redirrect from http to https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top