【问题标题】:How add trailing slash in URl for 2 or more directories?如何在 URl 中为 2 个或更多目录添加斜杠?
【发布时间】:2012-03-22 12:30:13
【问题描述】:

nginx 服务器 如果我有两个或多个子目录,我在添加尾部斜杠时遇到问题

rewrite ^/([^.]*[^/])$ $1/ permanent; //this is working example if I have one directory

如果我有两个或多个子目录,如何添加斜杠?

http://example.com/foo/foo2/
http://example.com/foo/foo2/

【问题讨论】:

    标签: url nginx slash subdirectory


    【解决方案1】:

    捕获不带有斜杠的所有内容并为其添加斜杠。

    rewrite ^(.*[^/])$ $1/ permanent;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-18
      • 1970-01-01
      • 1970-01-01
      • 2020-08-17
      • 2021-02-04
      • 1970-01-01
      • 2019-04-08
      • 1970-01-01
      相关资源
      最近更新 更多