Nginx-自定义404页面 [英] Nginx - Customizing 404 page

查看:63
本文介绍了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中使用error_page属性配置.

You use the error_page property in the nginx config.

例如,如果您打算将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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆