在現在瀏覽器對 http 協定非常不友善的時代,每一個伺服器安裝完都要設定 SSL 走 https 協定
在 Ubuntu 22.04 LTSC 下的 Apache2 設定 http 自動跳轉 https ,監聽 80 端口,轉發至 https 協定
紀錄一下,直接從 Apache2 的虛擬主機裡面設定
<VirtualHost *:80>
ServerName idawn.one
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</VirtualHost>