【问题标题】:Nginx not redirect all requests to index.htmlNginx 不会将所有请求重定向到 index.html
【发布时间】:2020-08-10 01:37:10
【问题描述】:

我正在尝试将所有请求重定向到 Nginx 上的 index.html,但它没有重定向。

工作 -> https://www.example.com/reviews

不工作 -> https://www.example.com/reviews/

如果您在最后看到由于“/”斜线它不起作用,则在第二个 URL 中。

我在 Nginx 设置中使用以下设置

location / {
  try_files $uri /index.html;
}

【问题讨论】:

    标签: nginx routes devops nginx-location nginx-config


    【解决方案1】:

    Nginx 将目录(带有斜杠的 URL)与普通文件分开考虑。试试这个:

    location / {
      try_files $uri $uri/ /index.html;
    }
    

    【讨论】:

      猜你喜欢
      • 2013-02-15
      • 2016-05-04
      • 2019-02-02
      • 2012-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-22
      • 1970-01-01
      相关资源
      最近更新 更多