nginx 设置错误的自定义404页面跳转到500
来源:互联网 发布:js图片特效 编辑:程序博客网 时间:2024/05/01 22:48
5年前写的站, 当时是在apache下写的error page, 换了nginx后, 404页面直接跳到了500 服务器内部错误.
只需要在配置
try_files 的时候指定一下就可以了
我的是debian, 在/etc/nginx/site-available/default 里面location /
server{
- </pre><pre name="code" class="plain"> location / {
- <span style="white-space:pre"> </span>try_files $uri $uri/ /error/404.php?c=404 =404;
- <span style="white-space:pre"> </span>}
- <pre name="code" class="plain"><span style="white-space:pre"> </span>error_page 403 /error/403.php;
- <span style="white-space:pre"> </span>error_page 404 /error/404.php;
- <span style="white-space:pre"> </span>error_page 500 501 502 503 504 /error/500.php;
然后reload下nginx即可
参考http://wiki.nginx.org/HttpCoreModule#try_files
说明下, 我把页面放在了 网站目录下的error文件夹下. 比如网站放在/var/www/ 错误页面就在/var/www/error/403.php ...
测试的话很简单, 403是没权限比如你的网站目录css目录, 图片目录什么的, 404是不存在, 随便输个地址就可以, 500上是服务器的, 这里我停掉php-fpm来测试. 效果如下
aibang.com/show/696530421-425220173/product/15170647.html
aibang.com/show/696530421-425220173/product/15170667.html
aibang.com/show/696530421-425220173/product/15170689.html
aibang.com/show/696530421-425220173/product/15170709.html
aibang.com/show/696530421-425220173/product/15170745.html
aibang.com/show/696530421-425220173/product/15170769.html
aibang.com/show/696530421-425220173/product/15170795.html
aibang.com/show/696530421-425220173/product/15170821.html
aibang.com/show/696530421-425220173/product/15170869.html
aibang.com/show/696530421-425220173/product/15170925.html
aibang.com/show/696530421-425220173/product/15171001.html
aibang.com/show/696530421-425220173/product/15171065.html
aibang.com/show/696530421-425220173/product/15171159.html
aibang.com/show/696530421-425220173/product/15171185.html
aibang.com/show/696530421-425220173/product/15171219.html
aibang.com/show/696530421-425220173/product/15171351.html
aibang.com/show/696530421-425220173/product/15171411.html
aibang.com/show/696530421-425220173/product/15171459.html
aibang.com/show/696530421-425220173/product/15171491.html
aibang.com/show/696530421-425220173/product/15171527.html
aibang.com/show/696530421-425220173/product/15171549.html
aibang.com/show/696530421-425220173/product/15171573.html
aibang.com/show/696530421-425220173/product/15171609.html
aibang.com/show/696530421-425220173/product/15171637.html
aibang.com/show/696530421-425220173/product/15171667.html
aibang.com/show/696530421-425220173/product/15171761.html
aibang.com/show/696530421-425220173/product/15171775.html
aibang.com/show/696530421-425220173/product/15171799.html
aibang.com/show/696530421-425220173/product/15171819.html
aibang.com/show/696530421-425220173/product/15171831.html
aibang.com/show/696530421-425220173/product/15171841.html
aibang.com/show/696530421-425220173/product/15171855.html
aibang.com/show/696530421-425220173/product/15171891.html
aibang.com/show/696530421-425220173/product/15171909.html
aibang.com/show/696530421-425220173/product/15171929.html
aibang.com/show/696530421-425220173/product/15171955.html
aibang.com/show/696530421-425220173/product/15171981.html
aibang.com/show/696530421-425220173/product/15172015.html
aibang.com/show/696530421-425220173/product/15172033.html
aibang.com/show/696530421-425220173/product/15172057.html
aibang.com/show/696530421-425220173/product/15172141.html
aibang.com/show/696530421-425220173/product/15172179.html
aibang.com/show/696530421-425220173/product/15172221.html
aibang.com/show/696530421-425220173/product/15172237.html
aibang.com/show/696530421-425220173/product/15172247.html
aibang.com/show/696530421-425220173/product/15172261.html
aibang.com/show/696530421-425220173/product/15172323.html
aibang.com/show/696530421-425220173/product/15172377.html
aibang.com/show/696530421-425220173/product/15172509.html
aibang.com/show/696530421-425220173/product/15172515.html
k518.com/kunming/zhuankeyiyuan/a9707677.html
k518.com/kunming/zhuankeyiyuan/a9707718.html
k518.com/kunming/zhuankeyiyuan/a9707756.html
k518.com/kunming/zhuankeyiyuan/a9707786.html
k518.com/kunming/zhuankeyiyuan/a9707819.html
k518.com/kunming/zhuankeyiyuan/a9707842.html
k518.com/kunming/zhuankeyiyuan/a9707861.html
k518.com/kunming/zhuankeyiyuan/a9707938.html
k518.com/kunming/zhuankeyiyuan/a9707920.html
k518.com/kunming/zhuankeyiyuan/a9707888.html
k518.com/kunming/zhuankeyiyuan/a9708219.html
k518.com/kunming/zhuankeyiyuan/a9708192.html
k518.com/kunming/zhuankeyiyuan/a9708163.html
k518.com/kunming/zhuankeyiyuan/a9708145.html
k518.com/kunming/zhuankeyiyuan/a9708128.html
k518.com/kunming/zhuankeyiyuan/a9708100.html
k518.com/kunming/zhuankeyiyuan/a9708074.html
k518.com/kunming/zhuankeyiyuan/a9708054.html
k518.com/kunming/zhuankeyiyuan/a9708036.html
k518.com/kunming/zhuankeyiyuan/a9708010.html
k518.com/kunming/zhuankeyiyuan/a9708441.html
k518.com/kunming/zhuankeyiyuan/a9708418.html
k518.com/kunming/zhuankeyiyuan/a9708396.html
k518.com/kunming/zhuankeyiyuan/a9708377.html
k518.com/kunming/zhuankeyiyuan/a9708362.html
k518.com/kunming/zhuankeyiyuan/a9708340.html
k518.com/kunming/zhuankeyiyuan/a9708314.html
k518.com/kunming/zhuankeyiyuan/a9708297.html
k518.com/kunming/zhuankeyiyuan/a9708273.html
k518.com/kunming/zhuankeyiyuan/a9708258.html
k518.com/kunming/zhuankeyiyuan/a9708828.html
k518.com/kunming/zhuankeyiyuan/a9708800.html
k518.com/kunming/zhuankeyiyuan/a9708782.html
k518.com/kunming/zhuankeyiyuan/a9708766.html
k518.com/kunming/zhuankeyiyuan/a9708748.html
k518.com/kunming/zhuankeyiyuan/a9708726.html
k518.com/kunming/zhuankeyiyuan/a9708669.html
k518.com/kunming/zhuankeyiyuan/a9708642.html
k518.com/kunming/zhuankeyiyuan/a9708623.html
k518.com/kunming/zhuankeyiyuan/a9708600.html
k518.com/kunming/zhuankeyiyuan/a9708866.html
k518.com/kunming/zhuankeyiyuan/a9708889.html
k518.com/kunming/zhuankeyiyuan/a9708910.html
k518.com/kunming/zhuankeyiyuan/a9708933.html
k518.com/kunming/zhuankeyiyuan/a9708946.html
k518.com/kunming/zhuankeyiyuan/a9708962.html
k518.com/kunming/zhuankeyiyuan/a9708980.html
k518.com/kunming/zhuankeyiyuan/a9709002.html
k518.com/kunming/zhuankeyiyuan/a9709021.html
k518.com/kunming/zhuankeyiyuan/a9709032.html
- nginx 设置错误的自定义404页面跳转到500
- nginx 设置错误的自定义404页面跳转到500
- nginx 404 跳转到自定义的页面
- nginx自定义500,502,504错误页面无法跳转
- JSP错误页面跳转自定义页面设置
- 分享 ASP.Net 网站设置 404错误跳转到指定页面的三种方法
- nginx自定义404错误页面
- 配置nginx的403错误页面跳转
- Tomcat 设置自定义的 404 错误页面
- 自定义的404错误页面不能跳转的问题
- nginx禁止直接通过ip进行访问并跳转到自定义500页面
- 如何跳转到app的设置页面
- iOS跳转到APP的设置页面
- Nginx设置404错误页面的几种方法
- Nginx网站自定义404错误页面
- 为nginx反向代理设置自定义错误页面
- NGINX自定义404页面设置方法
- nginx如何设置自定义404页面
- 小波变换 完美通俗解读
- Python学习手册笔记
- 对回调的理解
- redis 下载以及安装
- RK3188 触摸屏调试(基于radxa rock)
- nginx 设置错误的自定义404页面跳转到500
- 魔兽国画水墨风格图赏:美到不行
- IOS 键盘回收
- quartz
- ant 常用文件操作
- wordpress博客最近变慢之解决(fonts.google.com)
- Json
- IOS中 Block简介与用法(一)
- 【leetcode】Construct Binary Tree from Inorder and Postorder Traversal