nginx 404 跳转到自定义的页面

1. 自己写了一个error.html页面


2. 更改nginx.conf在http定义区域加入: fastcgi_intercept_errors on;


3. 更改nginx.conf中在server 区域加入: error_page 404  /404.html 


4. 重启ngnix


另外,有一个8000端口的错误页面也要跳转到80的error页面,

在server 8000下添加 error_page 404 error, 另外 include error.conf


# the difference when adding URI to proxy_pass directive:
# http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass

# why I use variable but not staticlly config the url:
# http://forum.nginx.org/read.php?2,215830,215832#msg-215832
#
# and resolver is needed, or will get 502, ref:
# https://stackoverflow.com/questions/5743609/
#
# why use rewrite: http://wiki.nginx.org/HttpProxyModule#proxy_pass

resolver 127.0.0.1;

location /error {
    proxy_pass  http://127.0.0.1:80;
}

location /images {
    proxy_pass  http://127.0.0.1:80;
}

location /js {
    proxy_pass  http://127.0.0.1:80;
}

location /css {
    proxy_pass  http://127.0.0.1:80;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值