rewrite last: 用replacement这个URI进行新的location匹配
https://192.168.137.2:2443/first/index.html
location /first {
rewrite /first(.*) /second$1 last ;
alias /var/www/html;
}
[192.168.137.2] -[192.168.137.1]- 192.168.137.1 - - [18/Sep/2020:23:31:47 +0800]
"GET /first/index.html HTTP/1.1" 404 153 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0"
"-" "/usr/local/nginx/html/second/index.html"
此时找不到second匹配 ,报错
添加:
location /second {
rewrite /first(.*) /second$1 break ;
alias /var/www/html/second;
}