node.js - 为何我的网站不显示【404】,而显示【Cannot GET ****** 】?
怪我咯
怪我咯 2017-04-17 15:31:10
0
2
371

是Nginx在VPS上搭建的Hexo博客,配置404页面的时候才发现。

localhost:4000/404.html 是可以正常显示的。

但是比如我输入 localhost:4000/asdasdasd 这样一个不存在的页面
他就会显示 Cannot GET /asdasdasd/

不太懂是哪里的问题,能不能把Cannot GET换成404?

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(2)
伊谢尔伦

There is no relevant routing set in the nginx configuration file.

You can read this post, the general idea is how to route all 404 errors to a custom page.

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        . . .

        error_page 404 /custom_404.html;
        location = /custom_404.html {
                root /usr/share/nginx/html;
                internal;
        }
}
洪涛

Just set the public directory generated by hexo g to the root directory of the website. The performance of hexo s is too low.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template