Nginx: Remove double slashes from URLs nginx去双斜杆

来自linux中国网wiki
跳到导航 跳到搜索

Q

百度云加速出了问题 有些 站出了 dobule slashes

https://m.cailu.net/download

slove


    ssl_prefer_server_ciphers  on;
   # Remove double slashes from URLs
   merge_slashes off;
   rewrite ^([^.]*?\/)\/+(.*)$ $1$2 permanent;

    location / {
   #   proxy_pass http://12.16.20.8:3394;
        add_header X-Frame-Options SAMEORIGIN;
        proxy_pass http://proxy_node_nuxt_mobile.net;
    }



#这个应该也是行的 
可以通过nginx对多个斜杠进行处理
如访问 public//view//a//test.html 重定向到 public/view/a/test.html

merge_slashes off;
rewrite (.*)//(.*) $1/$2 permanent;

see also

nginx: Remove double slashes from URLs