サーバ用Raspberry Pi の設定9
http アクセスを https にリダイレクトします。
単純に 80 番ポートを閉じてもいいのですが、もともと http でページを公開していたので、http でアクセスしてきたら、https へリダイレクトするように設定します。
Apache の http 用の設定ファイルの内容を以下にします。
<VirtualHost *:80> ServerName sirius10.dip.jp RewriteEngine on RewriteCond %{HTTP_HOST} ^sirius10\.dip\.jp RewriteRule ^/(.*)$ https://sirius10.dip.jp/$1 [R=301,L] </VirtualHost>
rewrite を有効にします。
$ sudo a2enmod rewrite
Enabling module rewrite.
To activate the new configuration, you need to run:
systemctl restart apache2
Apache を再起動します。
$ sudo service apache2 restart
ブラウザで http://sirius10.dip.jp を開きます。
https にリダイレクトされました。
ディスカッション
コメント一覧
まだ、コメントがありません