nginx 配置:
location /first {
#rewrite /first(.*) /second$1;
root /var/www/html/;
}
[192.168.137.2] -[192.168.137.1]- 192.168.137.1 - - [10/Sep/2020:06:02:50 +0800]
"GET /first/a.txt HTTP/1.1" 200 16 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0" "-"
"/var/www/html/first/a.txt"
配置为root后:
访问 https://192.168.137.2:2443/first/a.txt 正常
rewrite:
location /first {
#rewrite /first(.*) /second$1;
root /var/www/html/;
}
请求https://192.168.137.2:2443/first/a.txt,
[192.168.137.2] -[192.168.137.1]- 192.168.137.1 - - [10/Sep/2020:06:08:09 +0800]
"GET /first/a.txt HTTP/1.1" 200 16 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0" "-"
"/var/www/html/first/a.txt"
配置rewrite:
[192.168.137.2] -[192.168.137.1]- 192.168.137.1 - - [10/Sep/2020:06:09:05 +0800] "GET /first/a.txt HTTP/1.1" 404 153 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0" "-"
"/var/www/html/second/a.txt"