nginx自定义404、403页面

1、在nginx的http模块加入:

fastcgi_intercept_errors on;

2、在server模块加入

location / {
        root   /data;
        index  index.html index.htm yunmai.html;
        error_page   403  /403.html;
        error_page   404  /404.html;
    location = /403.html {
        root   /usr/share/nginx/html;
    }
    location = /404.html {
        root   /usr/share/nginx/html;
    }

3、编辑以下路径下的自定义页面

4、重载nginx

nginx -s reload

  

参考:https://blog.51cto.com/hunkz/1840200

猜你喜欢

转载自www.cnblogs.com/caidingyu/p/10868682.html