rewrite只能放在server{},location{},if{}中,并且只能对域名后边的除去传递的参数外的字符串起作用. 例如http://seanlook.com/a/we/index.php?id=1&u=str 只对/a/we/index.php重写. 语法: rewrite regex replacement [flag]; 如果相对域名或参数字符串起作用,可以使用全局变量匹配,也可以使用proxy_pass反向代理. 1.location正则写法 一个示例: location =…