卡饭网 > 其他 > 正文

LNMP系列教程之五:设置404错误页面

来源:本站整理 作者:梦在深巷 时间:2013-05-17 22:07:31

在之前的文章中分享到"设置301重定向方法 "文章,提到301,那肯定也要说说404错误页面吧。因为我们默认安装了LNMP后404页面不会自动设置,也不会默认到程序的404错误页面,而需要我们手工设置。具体如何设置呢?我们一起往下看。

第一步,编辑 /usr/local/nginx/conf/nginx.conf 文件,在http区域添加下面的代码;

fastcgi_intercept_errors on;

LNMP系列教程之五:设置404错误页面

第二步,编辑你需要添加404页面的网站的conf文件,对应在 usr/local/nginx/conf/vhost/XXXX.com.conf,在server区域添加代码;

error_page 404 = /404.html;

第三步,重启 LNMP;

/root/lnmp restart

总结,我们可以通过 /usr/local/nginx/sbin/nginx -t 来测试返回状态是否正确。

the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

configuration file /usr/local/nginx/conf/nginx.conf test is successful

如果是上述返回状态,就是正确的。

本文固定链接: http://www.laozuo.org/215.html | 老左博客

相关推荐