weixin_41287260
2019-12-09 17:22 阅读 1.1k
已采纳

Nginx配置404页面无效

主要的相关配置:

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    # fastcgi_intercept_errors on | off;
    # 启用自定义错误页面
    fastcgi_intercept_errors on; 

    server {
        listen       80;
        server_name  localhost;

        charset utf8;

        access_log  logs/80-access.log  main;
        error_log  logs/80-error.log error;

        location / {
            root   html;
            index  index.html index.htm;
        }

        # 使用腾讯公益404页面
        error_page  404              /404.html;
        location = /404.html {
            root   html;
        }

        # error_page 404 = http://www.test.com/error.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
}

注:404.html和50x.html都在html文件夹下,404页面无效,还是默认的界面如下:
file

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    weixin_43466240 weixin_43466240 2019-12-10 10:42

    配置完,进入到nginx目录下, nginx -t 检查是否有错,然后 nginx -s reload 重启一下, 如果nginx 本身没有启动,那么 strat nginx 启动

    点赞 1 评论 复制链接分享
  • bairuijin 请稍后再查看 2019-12-09 17:36

    配置完成重启nginx了吗

    点赞 评论 复制链接分享

相关推荐