如何讓Apache Server強制所有網頁連線都使用https呢?
關鍵在該目錄下使用 .htaccess
編輯該檔案, RewriteEngine on 下一行增加如下
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Synology NAS用 [文字編輯器] 這個工具會失敗喔(無法寫入)。
因為是受保護的檔案,建議用ssh進去後sudo vi該檔案,這樣就正常多了。
參考資料來源:
https://blog.tayanswa.tw/technical/apache-li-yong-htaccess-she-ding-qiang-zhi-dao-xiang-https