nginx rewrite WITHOUT change url

后端 未结 2 973
温柔的废话
温柔的废话 2020-12-24 08:09

I want to use rewrite function in my nginx server.

When I try \"http://www.example.com/1234\", I want to rewrite \"http://www.example.com/v.php?id=1234\" and want to

2条回答
  •  天命终不由人
    2020-12-24 08:40

    Reference: http://wiki.nginx.org/HttpRewriteModule#rewrite

    If the replacement string begins with http:// then the client will be redirected, and any further >rewrite directives are terminated.

    So remove the http:// part and it should work:

    location ~ /[0-9]+ {
            rewrite "/([0-9]+)" /v.php?id=$1 break;
    }
    

提交回复
热议问题