nginx中斜杠(/)详解

通过nginx代理访问地址:http://127.0.0.1/v1/pt/apply/page

1.location、proxy_pass都不加斜杠

location /v1 {
    proxy_pass http://127.0.0.1:8899;
}


 实际访问代理地址:http://127.0.0.1:8899/v1/pt/apply/page

2.location加斜杠,proxy_pass不加斜杠

location /v1/ {
    proxy_pass http://127.0.0.1:8899;
}


实际访问代理地址:http://127.0.0.1:8899/v1/pt/apply/page

3.location不加斜杠,proxy_pass加斜杠

location /v1 {      
    proxy_pass http://127.0.0.1:8899/;
}


实际访问代理地址:http://127.0.0.1:8899//pt/apply/page

4.location、proxy_pass都加斜杠

location /v1/ {
    proxy_pass http://127.0.0.1:8899/;
}


实际访问代理地址:http://127.0.0.1:8899/pt/apply/page

5.location不加斜杠,proxy_pass加"v1"

location /v1 {
    proxy_pass http://127.0.0.1:8899/v1;
}


实际访问代理地址:http://127.0.0.1:8899/v1/pt/apply/page

6.location加斜杠,proxy_pass加"v1"

location /v1/ {
    proxy_pass http://127.0.0.1:8899/v1;
}


实际访问代理地址:http://127.0.0.1:8899/v1pt/apply/page

7.location不加斜杠,proxy_pass加"v1/"

location /v1 {
    proxy_pass http://127.0.0.1:8899/v1/;
}


实际访问代理地址:http://127.0.0.1:8899/v1//pt/apply/page

8.location加斜杠,proxy_pass加"v1/"

location /v1/ {
    proxy_pass http://127.0.0.1:8899/v1/;
}


实际访问代理地址:http://127.0.0.1:8899/v1/pt/apply/page

你可能感兴趣的:(nginx)