Nginx 去除多斜杠 (//)

某些历史遗留问题,可能链接中有出现双斜杠或者是多斜杠现象,需要去掉多余的只保留1个斜杠。

Nginx直接再server或者是对应的位置加上下面两行配置即可

server {
          listen 80;
          server_name localhost;
          location / {
            proxy_pass http://nginx-A;
          }

          //去除多斜杠的配置
          merge_slashes off;
          rewrite (.*)//(.*) $1/$2 permanent;
    }

示例:

去除前:http://localhost//aa///bc

去除后:http://localhost/a/b/c

猜你喜欢

转载自blog.csdn.net/qq_33601179/article/details/123960267