jagsler 的回答还可以,但必须牢记这一点:
server {
# you config here (servername, port, etc.)
location /pages {
#***modified . = any character, so escape literal dots***
rewrite ^/pages/(.*)\.html$ /show_page.php?name=$1? last;
#***the line bellow will only be executed if the rewrite condition***
#***equals false, this is due to the "last" modifier in the rewrite rule***
include php.conf;
}
# instead of the php location block also just add the include
include php.conf;
}
因此请注意重写规则中修饰符的行为“最后”意味着如果重写条件等于 true,则重写请求的 uri 并跳转到适合新重写的 uri 的位置块。
Another modifier is the "break", wich means if the rewrite condition equals true then rewrite the requested uri BUT DO NOT JUMP, instead stay in the same location block and continue to the next line inside the block