<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>

                [TOC] ## root與alias區別 ~~~ location ^~ /admin { alias /var/www/admin/; index regist.html; } location / { root /data/html/; index index.html index.html; } ~~~ 復制 * root的處理結果是:root路徑+location路徑 * alias的處理結果是:使用alias路徑替換location路徑 * alias是一個目錄別名的定義,root則是最上層目錄的定義 * 重要的區別是alias后面必須要用“/”結束,而root不強制 ### root與alias 后跟 "/" 的區別 ~~~ location ^~ /dev-popularize/ { # 必須有 dev-popularize 這個目錄,靜態資源文件都在這個目錄下 root /Users/wxq/Desktop/shounaer/dist; # 不需要有 dev-popularize 這個目錄,靜態資源文件直接放在dist目錄下 root /Users/wxq/Desktop/shounaer/dist/; # 則 dist 目錄下,無論有沒有dev-popularize 都不行,會報 403 alias /Users/wxq/Desktop/shounaer/dist; # 則 dist 目錄下,直接放你的靜態資源文件就行 # alias /Users/wxq/Desktop/shounaer/dist/; index regist.html; } ~~~ ## location 開頭 語法規則:`location \[ = | ~ | ~ \* | ^~ \] /uri/ { … }` ### 以 = 開頭,表示精確匹配 ~~~ # 精確匹配,必須是127.0.0.1/ location = / { #規則A } # 精確匹配,必須是127.0.0.1/login location = /login { #規則B } ~~~ ### 以 ^~ 開頭,表示uri以某個常規字符串開頭 nginx不對url做編碼 ~~~ ## 非精確匹配,并且不區分大小寫,比如127.0.0.1/static/js. location ^~ /static/ { #規則C } ~~~ ### ~ 開頭,表示區分大小寫的正則匹配 ~~~ location ~ \.(gif|jpg|png|js|css)$ { #規則D } ~~~ ### ~\* 開頭,表示不區分大小寫的正則匹配 ~~~ ## 不區分大小寫,匹配.png結尾的 location ~* \.png$ { #規則E } ~~~ ### !~ 和!~\* 分別為區分大小寫不匹配及不區分大小寫不匹配 的正則 ~~~ ## 區分大小寫,匹配不以.xhtml結尾的 location !~ \.xhtml$ { #規則F } location !~* \.xhtml$ { #規則G } ~~~ ### / 通用匹配,任何請求都會匹配到 ~~~ location / { #規則H } ~~~ ## 匹配順序 首先匹配= ; 其次匹配^~; 再其次是按文件中順序的正則匹配; 最后是交給 / 通用匹配; 當有匹配成功時候,停止匹配,按當前匹配規則處理請求 ## ** Nginx常規配置** ~~~ ``` / 基于uri目錄匹配 =表示把URI作為字符串,以便與參數中的uri做完全匹配 ~表示正則匹配URI時是字母大小寫敏感的 ~\*表示正則匹配URI時忽略字母大小寫問題 ^~表示正則匹配URI時只需要其前半部分與uri參數匹配即可 ``` ``` location = /baidu.html { proxy_pass http://www.baidu.com; } location /static { #root的處理結果是:root路徑+location路徑 #root /usr/www/; #alias的處理結果是:使用alias路徑替換location路徑 alias /usr/www/static/; index index.html; } #下載限速 location /download { alias /usr/www/download/; \# 限速2m limit_rate 2m; \# 30m之后限速 limit_rate_after 30m; } location ~\* \\.(gif|png|jpg|css|js)$ { root /usr/www/static/; } ~~~
                  <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>

                              哎呀哎呀视频在线观看