比如我们要配置这样一个地址http://webxue.cn/demo/
// demo.conf
location /demo/ {
alias /home/project/webxue.cn/demo/;
index index.html;
# 重要是这行
try_files $uri $uri/ /demo/index.html;
}
比如我们需要访问http://webxue.cn/demo
仍然可以跳转到http://webxue.cn/demo/
,就需要做uri重写
// demo.conf
location /demo {
rewrite ^/demo/?$ /demo/ permanent;
}