nginx 404错误页面配置详解

news/2024/7/4 8:30:44

nginx 错误页面配置

再主配置文件server中加入一个location模块即可
vim /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index 404.html;
# rewrite .* http://jd.com permanent;
# 这个是直接转向www.jd.com的页面
}
}

注意:

/usr/local/nginx/html/ 路径下必须有404.html这个文件!!!

为了简单,可以将css嵌入文件中,图片用base编码嵌入;如下:

[root@localhost html]# vim /usr/share/nginx/html/404.html
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
        <title>404</title>
        <style>
            .layout-table{display:table;height:100%;width:100%;vertical-align: middle;margin-top:150px}
            .layout-table-cell{display: table-cell;vertical-align: middle;text-align:center}
            .layout-tip{font-size:28px;color:#373737;margin: 0 auto;margin-top:16px;border-bottom: 1px solid #eee;padding-bottom: 20px;width: 360px;}
            #tips{font-size:18px;color:#666666;margin-top:16px;}
        </style>
    </head>
    <body class="layui-layout-body">
        <div class="layui-layout layui-layout-admin">
            
            <div class="layui-body">
                <div class="layout-table">
                    <div class="layout-table-cell">
                        <img src="自定义图片地址链接">
                        <p class="layout-tip">哎呀,找不到该页面啦!</p>
                        <p id="tips">请检查您的网络连接是否正常或者输入的网址是否正确</p>
                    </div>
                </div>
            </div>
        </div>
        
    </body>
</html>

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-VgUGVS47-1602667315967)(assets/1561964133748.png)]

直接用IP地址访问网页就好了


http://www.niftyadmin.cn/n/3585857.html

相关文章

PHP GD库相关图像生成和处理函数

首先分析一下GD库所提供的函数&#xff0c;依据功能作了划分&#xff1a;&#xff08;这只是常用的基础级函数&#xff0c;更高级的函数稍后再作研究&#xff09; 1. create // 图像生成 A.绘制图像 ?12imageCreate // 基于调色板(256色)的图像(gif/*)imageCreateTrueColor //…

WebSocket使用(C++环境)(二) --- libwebsockets库的安装与使用

一、参考网址&#xff1a; libwebsockets官网&#xff1a; https://libwebsockets.org/ libwebsockets的API&#xff1a;https://libwebsockets.org/lws-api-doc-master/html/modules.html https://libwebsockets.org/libwebsockets-api-doc.html 二、libwebsockets的安装 …

Cocos2d-x常用功能-Cocos2d-x用户交互事件处理:触摸、传感器、物理按键

第三阶段&#xff1a;常用功能3---Cocos2d-x常用功能-Cocos2d-x用户交互事件处理&#xff1a;触摸、传感器、物理按键&#xff08;共6部分&#xff09;1.Cocos2d-x单点触摸Size size Director::getInstance()->getVisibleSize(); autolabel LabelTTF::creat…

PHP输出图像imagegif、imagejpeg与imagepng函数用法

详细的分析了imagegif()、imagejpeg()、imagepng()和imagewbmp()函数的功能、参数含义及使用技巧 imagegif()、imagejpeg()、imagepng() 和 imagewbmp() 函数分别允许以 GIF、JPEG、PNG 和 WBMP 格式将图像输出到浏览器或文件。 PHP 输出图像 PHP 允许将图像以不同格式输出&…

nginx 版本升级和添加模块详解

版本升级 把1.16.0版本升级为1.18.0 查看本机现在版本为1.16.0 [rootlocalhost ]# /usr/local/nginx/sbin/nginx -v nginx version: nginx/1.16.0 1&#xff0c;下载1.18.0的版本 [rootlocalhost ]# wget http://nginx.org/download/nginx-1.18.0.tar.gz 2&#xff0c;解压 […

nginx 证书申请和证书的使用

1&#xff0c;证书申请 申请证书要有阿里云的域名 阿里云提供免费的证书&#xff0c;不需要人工审核&#xff0c;用来做测试是非常不错的选择&#xff0c;申请地址如下URL。 购买完了以后申请证书 证书签发之后&#xff0c;可以在列表中可以看到状态栏中为 已签发 &#xff0…

getopt和getopt_long函数

本文转自&#xff1a;http://blog.csdn.net/cashey1991/article/details/7942809 平时在写程序时常常需要对命令行参数进行处理&#xff0c;当命令行参数个数较多时&#xff0c;如果按照顺序一个一个定义参数含义很容易造成混乱&#xff0c;而且如果程序只按顺序处理参数的话&a…

'mysql.innodb_index_stats' doesn't exist when using LOCK TABLES问题原因及解决方法

前言 下面总结的是使用mysqldump备份整个数据库时的常见的一个报错的原因及解决方法。 报错如下 mysqldump: Got error: 1146: Table ‘mysql.innodb_index_stats’ doesn’t exist when using LOCK TABLES 执行导出数据库时报1146&#xff0c;mysql_innodb_table_stats显示没有…