为Nginx自定义404,502错误页面的方法

为Nginx自定义404,502错误页面的方法,第1张

为Nginx自定义404502错误页面的方法 首先打开nginx.conf文件,在fastcgi_temp_file_write_size 128k; 下面添加

fastcgi_intercept_errors on;注意,包括;号

然后在需要定义的站点的里面添加

error_page 404 = /404.htm;
例如:
复制代码 代码如下:
server
{
listen 80;
server_name www.deepvps.com;
index index.html index.htm index.php;
error_page 404 = /404.htm;
include location.conf;
root /home/www/logs;
}

记得404页面放在站点的跟目录下…

测试配置
/usr/local/nginx/sbin/nginx -t

没错误就重启nginx
/etc/init.d/nginx restart

BTW,其他页面也是这样定义

error_page 502 = /502.htm;

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/895995.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-14
下一篇 2022-05-14

发表评论

登录后才能评论

评论列表(0条)

保存