网站运营
位置:首页>> 网站运营>> 为Nginx自定义404,502错误页面的方法

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

  发布时间:2023-11-04 04:01:46 

标签:404,502

首先打开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;

0
投稿

猜你喜欢

手机版 网站运营 asp之家 www.aspxhome.com