bestlong 怕失憶論壇

標題: 讓 http 網址自動轉址 https [打印本頁]

作者: bestlong    時間: 2010-10-30 12:53     標題: 讓 http 網址自動轉址 https

資料參考 http://a-wei.net/archives/288

使用 mod_rewrite 模組, 讓 apache 自動的從 http 非加密連線,轉址到 https 的加密連線.

修改 httpd.conf 設定檔

一、整個網站轉移
在 VirtualServer 內的 Directory

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

二、某個目錄做自動轉移

在該目錄內

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

這樣就會自動轉移了, 另外寫在網站目錄內的 .htaccess 也是可以的.




歡迎光臨 bestlong 怕失憶論壇 (http://www.bestlong.idv.tw/) Powered by Discuz! X1.5