Nginx将所有请求转发到某固定页面(挂维护页面)
Posted geekfly
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Nginx将所有请求转发到某固定页面(挂维护页面)相关的知识,希望对你有一定的参考价值。
location /
try_files '' /index.html;
location = /index.html
root /opt;
index index.html;
- 重启nginx
注意:index不能再/root目录下,否则报错403 forbidden
放一个更新常用的页面代码,可直接修改,无其他css文件引入。
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<title>温馨提醒</title>
<style type="text/css">
body,div,h3,h4,li,olmargin:0;padding:0
bodyfont:14px/1.5 'Microsoft YaHei','微软雅黑',Helvetica,Sans-serif;min-width:1200px;background:#f0f1f3;
:focusoutline:0
h3,h4,strongfont-weight:700
acolor:#428bca;text-decoration:none
a:hovertext-decoration:underline
.error-pagebackground:#f0f1f3;padding:80px 0 180px
.error-page-containerposition:relative;z-index:1
.error-page-mainposition:relative;background:#f9f9f9;margin:0 auto;width:617px;-ms-box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:50px 50px 70px
.error-page-main:beforecontent:'';display:block;height:7px;position:absolute;top:-7px;width:100%;left:0
.error-page-main h3font-size:24px;font-weight:400;border-bottom:1px solid #d0d0d0
.error-page-main h3 strongfont-size:54px;font-weight:400;margin-right:20px
.error-page-main h4font-size:20px;font-weight:400;color:#333
.error-page-actionsfont-size:0;z-index:100
.error-page-actions divfont-size:14px;display:inline-block;padding:30px 0 0 10px;width:50%;-ms-box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;color:#838383
.error-page-actions ollist-style:decimal;padding-left:20px
.error-page-actions liline-height:2.5em
.error-page-actions:beforecontent:'';display:block;position:absolute;z-index:-1;bottom:17px;left:50px;width:200px;height:10px;-moz-box-shadow:4px 5px 31px 11px #999;-webkit-box-shadow:4px 5px 31px 11px #999;box-shadow:4px 5px 31px 11px #999;-moz-transform:rotate(-4deg);-webkit-transform:rotate(-4deg);-ms-transform:rotate(-4deg);-o-transform:rotate(-4deg);transform:rotate(-4deg)
.error-page-actions:aftercontent:'';display:block;position:absolute;z-index:-1;bottom:17px;right:50px;width:200px;height:10px;-moz-box-shadow:4px 5px 31px 11px #999;-webkit-box-shadow:4px 5px 31px 11px #999;box-shadow:4px 5px 31px 11px #999;-moz-transform:rotate(4deg);-webkit-transform:rotate(4deg);-ms-transform:rotate(4deg);-o-transform:rotate(4deg);transform:rotate(4deg)
</style>
</head>
<body>
<div class="error-page">
<div class="error-page-container">
<div class="error-page-main">
<h3>
<label>温馨提醒</label>
</h3>
<div class="error-page-actions">
<div style="width:100%;">
<!--<h4></h4>-->
<p >系统调试中</p>
<br/>
<br/>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
以上是关于Nginx将所有请求转发到某固定页面(挂维护页面)的主要内容,如果未能解决你的问题,请参考以下文章