【问题标题】:How to add slash to the end of every url except extensions?如何在除扩展名之外的每个网址的末尾添加斜杠?
【发布时间】:2014-10-14 04:04:07
【问题描述】:

需要帮助。

如何在除扩展名之外的每个网址的末尾添加斜杠?

我绑定使用

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

它正在工作,但在 每个 URL 的末尾添加斜杠,包括 css、js、图像...

【问题讨论】:

  • 你想要这个做什么?

标签: nginx rewrite php


【解决方案1】:

我认为这对你有用。遗憾的是,我们在 Nginx 中没有 NOT 的语法,所以我们必须进行空匹配,然后使用 / 来匹配其他任何内容。

location ~* ^.+\.(?:css|cur|js|jpg|jpeg|gif|htc|ico|png|html|xml)$ {
    # empty
}
location / {
    rewrite ^(.*[^/])$ $1/ permanent;
}

更多信息here

【讨论】:

    猜你喜欢
    • 2010-11-25
    • 2013-01-18
    • 2011-08-21
    • 2018-02-18
    • 2012-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多