If in the line of replacement arguments are indicated, then the rest of the request arguments are appended to them. To avoid having them appended, place a question mark as the last character:
rewrite ^/users/(.*)$ /show?user=$1? last;
如果可替换部分的参数都指明了,剩下的参数就会追加到他们后面。为了避免这种情况,放置一个问号作为最后的字符。
对于上面的英文解释一直没有弄明白。
终于出了一个例子:
http://192.168.1.10/pg/demo/-2-4-1-3-4
重写是这样的:rewrite ^/(.*)-([0-9]+)$ $1?&p=$2? last;
如果加了?,访问以上的链接机会访问http://192.168.1.10/pg/demo/-2
页面,即分页的第2页,
如果没有加问号rewrite ^/(.*)-([0-9]+)$ $1?&p=$2 last;
访问以上页面就会访问http://192.168.1.10/pg/demo/-4
即第4个分页
所以,?改变了重写时截取参数的位置。有问号时截取第一个参数,后面的都忽略;没有问号,截取最后一个,前面的忽略!