首先打开nginx.conf文件,在fastcgi_temp_file_write_size 128k; 下面添加 fastcgi_intercept_errors on;注意,包括;号 然后在需要定义的站点的里面添加 error_page 404 = /404.htm; 例如:
复制代码代码如下:
server
{
listen 80;
server_name www.tuohang.net;
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;