検索apache redirect http to https
してこちらにたどり着きました。これは私がubuntuで行ったことです:
1) モジュールを有効にする
sudo a2enmod rewrite
sudo a2enmod ssl
2) サイト構成を編集する
ファイルを編集
/etc/apache2/sites-available/000-default.conf
内容は次のとおりです。
<VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile <path to your crt file>
SSLCertificateKeyFile <path to your private key file>
# Rest of your site config
# ...
</VirtualHost>
- SSL モジュールには証明書が必要であることに注意してください。既存のものを指定するか (購入した場合) 、自己署名証明書を自分で生成する必要があります。
3) apache2 を再起動します。
sudo service apache2 restart