以Apache2的環境為例,並且已經啟用Apache2 的 rewrite 模組也開啓了。


只要編寫在該網站目錄中的 .htaccess 即可,範例如下:

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

紅字的部份要依你自己的環境來設定。

2010/11/17 補充說明:

設定啓用 RewriteEngine 時, Apache的AllowOverride 也必須設定為 All 否則將無法正常運作

 



參考來源:
http://phorum.study-area.org/index.php?topic=23778.0
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html


arrow
arrow
    全站熱搜

    Frank 發表在 痞客邦 留言(0) 人氣()