顯示廣告
隱藏 ✕
看板 Knuckles_note
作者 Knuckles (站長 那克斯)
標題 Rewrite
時間 2012年06月02日 Sat. PM 08:01:41


http://bbs.flash2u.com.tw/dispbbs_54_152086_2.html
http://www.widexl.com/tutorials/mod_rewrite.html

Apache mod_rewrite規則重寫的標誌一覽

    1) R[=code](force redirect) 強制外部重定向
    強制在替代字元串加上http://thishost[:thisport]/開頭重定向到外部的URL.如果code不指定,將用缺省的302 HTTP狀態碼。
    2) F(force URL to be forbidden)禁用URL,返回403HTTP狀態碼。
    3) G(force URL to be gone) 強制URL為GONE,返回410HTTP狀態碼。
    4) P(force proxy) 強制使用代理轉發。
    5) L(last rule) 表明目前規則是最後一則規則,停止分析以後規則的重寫。
    6) N(next round) 重新從第一則規則開始執行重寫過程。
    7) C(chained with next rule) 與下一則規則關聯
    如果規則符合則正常處理,該標誌無效,如果不符合,那麼下面所有關聯的規則都跳過。
    8) T=MIME-type(force MIME type) 強制MIME類型
    9) NS (used only if no internal sub-request) 只用於不是內部子請求
    10) NC(no case) 不區分大小寫
    11) QSA(query string append) 追加請求字元串
    12) NE(no URI escaping of output) 不在輸出轉義特殊字元
    例如:RewriteRule /foo/(.*) /bar?arg=P1%3d$1 [R,NE] 將能正確的將/foo/zoo轉換成/bar?arg=P1=zoo
    13) PT(pass through to next handler) 傳遞給下一個處理
    例如:
    RewriteRule ^/abc(.*) /def$1 [PT] # 將會交給/def規則處理
    Alias /def /ghi
    14) S=num(skip next rule(s)) 跳過num條規則
    15) E=VAR:VAL(set environment variable) 設定環境變數


加上錯誤 log 檔來除錯

RewriteLog /var/log/rewrite.log
RewriteLogLevel 3



--
※ 作者: Knuckles 時間: 2012-06-02 20:01:41
※ 編輯: Knuckles 時間: 2012-06-04 00:16:05
※ 看板: KnucklesNote 文章推薦值: 0 目前人氣: 0 累積人氣: 91 
e)編輯 d)刪除 ^x)轉錄 同主題: =)首篇 [)上篇 ])下篇