2015年12月7日

Apache mod_rewrite 自動 HTTP 轉 HTTPS

請確認已載入 mod_rewrite 模組後,在 httpd.conf 加入下方設定,重啟 apache 即可

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

方法二
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]

沒有留言:

張貼留言