且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

nginx重写而无需更改URL

更新时间:2023-02-24 13:01:02

参考: http://wiki. nginx.org/HttpRewriteModule#rewrite

如果替换字符串以http://开头,则客户端将被重定向,并且任何其他> rewrite指令都将终止.

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

因此,删除http://部分,它应该可以工作:

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

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