# Nginx 自定义 404 页面
创建一个 404.html
,让它可以通过你的域名或者 IP 访问
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<p>亲,这是一个静态网站哦!建议您去扫动态网站的呢</p>
<p>Hey, this is a static website, don't waste your energy.</p>
</body>
</html>
编辑 nginx.conf
在 http
区域中添加以下代码
http {
fastcgi_intercept_errors on;
error_page 404 403 500 502 503 504 /404.html;
}
/404.html
表示自定义错误页面的路径
重启 Nginx
systemctl restart nginx
访问该域名或者 IP 不存在的路径时即可返回该页面
文章部分内容转载链接: