概述:我们知道,nginx使用try_files可以定义多个方式查找我们需要访问的内容,如果不存在我们可以最后使用=404 结束,返回404的状态,但有的时候,这样显得并不人性化,于是我们可以自己定义和跳转到我们指定的页面,比如首页,如下:
location ~ /(h5|pages|mobile)/ {
index index.html;
root /opt/data;
try_files $uri /$uri/index.html
@toindex;
}
location @toindex {
rewrite ^/(.*) https://www.123test.com/?from=toindex;
}

