Nginx重写URL,更改URL的部分

时间:2017-01-12 10:07:47

标签: nginx url-rewriting

Nginx是否可以像这样重写URL?

http://www.example.com/city/person/contact.php?id=name

http://www.example.com/city/person/name/contact

1 个答案:

答案 0 :(得分:0)

怎么样:

location ~ /city/person/(.*)/(.*) {
    rewrite ^/city/person/$2.php?id=$1 last;
}