強制把 80 轉到 443

編輯 httpd.conf
在 # End of proxy directives. 後加入下面幾句 (應該是加在哪裡都ok)

RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/?(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

不過需先確認是否有載入下面這個module

LoadModule rewrite_module modules/mod_rewrite.so
This entry was posted in Linux. Bookmark the permalink.