Nginx - 自定义 404 页面 [英] Nginx - Customizing 404 page
本文介绍了Nginx - 自定义 404 页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Nginx+PHP(在 fastCGI 上)非常适合我.当我输入一个不存在的 PHP 文件的路径时,我不会得到默认的 404 错误页面(任何无效的 .html 文件都会出现),而是得到一个未指定输入文件".
Nginx+PHP (on fastCGI) works great for me. When I enter a path to a PHP file which doesn't exist, instead of getting the default 404 error page (which comes for any invalid .html file), I simply get a "No input file specified.".
如何自定义这个 404 错误页面?
How can I customize this 404 error page?
推荐答案
您在 nginx 配置.
例如,如果您打算将 404 错误页面设置为 /404.html
,请使用
For example, if you intend to set the 404 error page to /404.html
, use
error_page 404 /404.html;
将 500 错误页面设置为 /500.html
就像:
Setting the 500 error page to /500.html
is just as easy as:
error_page 500 /500.html;
这篇关于Nginx - 自定义 404 页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文