秦时明月之君临天下
2019-12-09 17:22
采纳率: 0%
浏览 1.4k
已结题

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条回答 默认 最新

相关推荐 更多相似问题