引言:nginx作為反向代理伺服器, 有時候需要修改http請求中的uri;
nginx rewrite模組包含的指令
- break
- if
- return
- break
- 模組簡介
The ngx_http_rewrite_module module is used to change request URI using regular expressions, return redirects, and conditionally select configurations.
主要包含三種方式,
正則變回404、501錯誤; 根據條件修改uri;
nginx rewrite模組指令的執行順序該模組的指令可以出現在server/location下面,當然還有if區塊中;
the directives of this module specified on the server level are executed sequentially;
repeatedly:
- a location is searched based on a request URI;
-
the directives of this based on a request URI;🎼 if a request URI was rewritten, but not more than 10 times.
-
- rewrite指令的標記
<code><span>Syntax</span>: <span>rewrite regex replacement [flag];</span><span>Default</span>: <span> —</span><span>Context</span>: <span> server, location, if</span></code>
登入後複製
last ; stops processing the current set of ngx_http_rewsrite last ; stops processing the current set of ngx_http_rewsrite break ; stops processing the current set of ngx_http_rewrite_module directives as with the break directive;
redirect; returns a temporary redirect with the 302 code; used if a replacement string dohttpses
permanent ; returns a permanent redirect with the 301 code.-
- 這四個標記並非是必須的,如果缺失[flag],則順序向下執行;
- 流程圖
Class-
. ('pre-numbering').hide();
$(this).addClass('has-numbering').parent().append($numbering);
for (i = 1; i
').text(i));
};
$numbering.fadeIn(1700);
});
});
以上就介紹了nginx rewite指令模組,包含了正規表示式方面的內容,希望對PHP教學有興趣的朋友有所幫助。