Filed Under (Note) by a-wei on 04-07-2007

apache 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 也是可以的



Post a comment

Name: 
Email: 
URL: 
Comments: