当前位置:

nginx处理路径中的多个斜杠/

机器助手 |  2025-07-13
 30人浏览

前端引用css,js时如果写的…/…/之类的引用方式,那么在访问链接中加入多个斜杠会导致引用失败.

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

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

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

文章评论