zoukankan      html  css  js  c++  java
  • Nginx优雅显示错误页面

    1.跳转到网上

    #error_page配置的是http这种的网络地址
    [root@web01 conf.d]# cat error.conf 
    server {
        listen       80;
        server_name  linux.error.com;
    
        location / {
            root /code/error;
            index index.html;
            error_page 404 http://www.baidu.com;
        }
    }

    2.跳转本地文件

    [root@web01 /code/error]# vim /etc/nginx/conf.d/error.conf
    server {
        listen 80;
        server_name  linux.error.com;
    
        location / {
            root /code/error;
            index index.html;
            error_page 404 403 /404.jpg;
        }
    }

    3.访问PHP的错误页面跳转

    [root@web01 /code/error]# vim /etc/nginx/conf.d/error.conf
    server {
        listen 80;
        server_name  linux.error.com;
        root /code/error;
        index index.php;
        error_page 404 403 /404.html;
    
        location ~* .php$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
            if (!-e $request_filename) {
                rewrite (.*) http://linux.error.com/404.jpg;
            }
        }
    }
  • 相关阅读:
    Exp9 Web安全基础
    EXP8 Web基础
    Exp7 网络欺诈防范
    Exp6 信息搜集与漏洞扫描
    Exp5 MSF基础应用
    Exp4 恶意代码分析
    Exp3 免杀原理与实践
    Exp2 后门原理与实践 20154317
    正则表达Regex替换标签
    正则表达式
  • 原文地址:https://www.cnblogs.com/chenlifan/p/13652263.html
Copyright © 2011-2022 走看看