質問

私の構成は次のとおりです。

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バージョンは正しく機能しています。 vhost、http(80)とhttps(443)の両方を使用して、mod_rewriteを介して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 vhostの.htaccessファイルのHTTPからHTTPSにredirRectに書き換えルールを追加します。

#Redirrect from http to https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top