51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

nginx set 指令 rewitelog

nginx配置指令rewrite的last、break、redirect、permanent参数详解 - 简书 (jianshu.com)

server {
    listen       80;
    server_name  example.com;
    set $flag    "org";
location /noflag/ {
    set $flag "noflag";
    rewrite ^/noflag/(.*) /test/$1?capture=$1;
    set $flag "rewrite noflag";
    echo flag=[$flag];
    echo "noflag page";
    echo request=[$request];
    echo request_uri=[$request_uri];
    echo uri=[$uri] args=[$args];
    echo document_uri=[$document_uri] query_string=[$query_string];
}

server {
    listen 80;
    server_name example.com;
root /var/www/html;

location / {
    if ($request_uri = /path1) {
        rewrite ^ /path2 last;
    }
    if ($request_uri = /path3) {
        # 执行特定操作
    }
    if ($request_uri ~* "^/path4/.*$") {
        # 执行特定操作
    }
    if ($request_uri ~* "^/path5/(.*)$") {
        rewrite ^ /path6/$1 last;
    }

    # 默认操作
}

}

post 测试

浏览器没办法做 post 请求,除非自己写一个表单。

if ($request_method = POST){
	return 405;
}

赞(8)
未经允许不得转载:工具盒子 » nginx set 指令 rewitelog