【问题标题】:Nginx and 404 on try_files with .html带有 .html 的 try_files 上的 Nginx 和 404
【发布时间】:2015-07-15 23:02:03
【问题描述】:

鉴于此 SEF URL /attrazioni/madame-tussauds-londra.html 我需要调用真正的 URL,即/index.php?q=/attrazioni/madame-tussauds-londra.html

我有这个指令,但只适用于没有扩展名的 SEF URL,在这种情况下/attrazioni/madame-tussauds-londra/

location {
    try_files $uri $uri/ /index.php?q=$request_uri;
}

我错了吗?为什么带有尾随 .html 的 URL 不起作用并返回 404 页面?

【问题讨论】:

    标签: php html nginx rewrite


    【解决方案1】:

    不是真正的问题。在try_files 之后,我的配置确实包括:

    location ~* \.(html|htm|txt)$ {
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
        access_log off;
        expires 1d;
        break;
    }
    

    【讨论】:

      猜你喜欢
      • 2014-02-05
      • 2023-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-24
      • 2012-06-19
      • 2017-09-06
      • 1970-01-01
      相关资源
      最近更新 更多