<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ## Rewrite規則 rewrite功能就是,使用nginx提供的全局變量或自己設置的變量,結合正則表達式和標志位實現url重寫以及重定向。rewrite只能放在server{},location{},if{}中,并且只能對域名后邊的除去傳遞的參數外的字符串起作用,例如`http://seanlook.com/a/we/index.php?id=1&u=str`只對/a/we/index.php重寫。語法`rewrite regex replacement [flag];` 如果相對域名或參數字符串起作用,可以使用全局變量匹配,也可以使用proxy\_pass反向代理。 表明看rewrite和location功能有點像,都能實現跳轉,主要區別在于rewrite是在同一域名內更改獲取資源的路徑,而location是對一類路徑做控制訪問或反向代理,可以proxy\_pass到其他機器。很多情況下rewrite也會寫在location里,它們的執行順序是: 1. 執行server塊的rewrite指令 2. 執行location匹配 3. 執行選定的location中的rewrite指令 如果其中某步URI被重寫,則重新循環執行1-3,直到找到真實存在的文件;循環超過10次,則返回500 Internal Server Error錯誤。 ## write實例 ~~~bash http { # 定義image日志格式 log_format imagelog '[$time_local] ' $image_file ' ' $image_type ' ' $body_bytes_sent ' ' $status; # 開啟重寫日志 rewrite_log on; server { root /home/www; location / { # 重寫規則信息 error_log logs/rewrite.log notice; # 注意這里要用‘’單引號引起來,避免{} rewrite '^/images/([a-z]{2})/([a-z0-9]{5})/(.*)\.(png|jpg|gif)$' /data?file=$3.$4; # 注意不能在上面這條規則后面加上“last”參數,否則下面的set指令不會執行 set $image_file $3; set $image_type $4; } location /data { # 指定針對圖片的日志格式,來分析圖片類型和大小 access_log logs/images.log mian; root /data/images; # 應用前面定義的變量。判斷首先文件在不在,不在再判斷目錄在不在,如果還不在就跳轉到最后一個url里 try_files /$arg_file /image404.html; } location = /image404.html { # 圖片不存在返回特定的信息 return 404 "image not found\n"; } } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看