【问题标题】:nginx custom 404 error page does not return when with wrong links ending with ".html"当错误链接以“.html”结尾时,nginx 自定义 404 错误页面不返回
【发布时间】:2015-02-02 13:47:39
【问题描述】:

我有一个自定义的 404 页面,当查询一个不存在的地址时,它会正确返回,例如“www.example.com/test/testjihi”将正确返回我的自定义 404 页面。

但是,如果使用 .html 扩展名指定不存在的地址,例如:“www.example.com/test/testjihi.html”,则会返回默认的“找不到文件”页面,而不是自定义 404 页面。

我全局配置错误页面:

server {
    listen       443;
    server_name  localhost;
    root         /www;
    error_page   404 /404.html; # this is my custom page
    ...

有什么想法吗?

为糟糕的术语道歉;p

【问题讨论】:

    标签: php html nginx


    【解决方案1】:

    您可以在 nginx 配置中使用 error_page 属性。 看看这个链接:http://expressica.com/2008/03/22/nginx-set-up-error-pages/

    【讨论】:

    • 修复了它,感谢您链接中的一个 cmets。 fastcgi_intercept_errors 开启; proxy_intercept_errors on;
    • 好的,我很高兴你让它工作了!我第一次阅读您的帖子时没有看到您的示例代码:p
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-08-12
    • 2011-03-08
    • 2014-01-30
    • 2016-04-25
    • 2013-09-16
    • 2013-02-27
    • 1970-01-01
    相关资源
    最近更新 更多