017_nginx重定向需求

时间:2020-12-09 16:54:05

重定向的各种需求

需求一、

前端同事需要把特定的url进行重定向,实现如下:

location  / {
root /data/base.apiportal_opsweb;
index index.html index.htm;
if ($request ~ product|api){ #url中包含product或api的都进行跳转
rewrite /(.*) /index.html break; #原始的请求url还在,但实际已经重定向到新的访问地址了
}
}

需求二、