1.网站维护页面背景
网站升级需要停服的情况下,需要准备维护页面,单单准备一个维护页面也是不够的,很多用户会把登陆页面比如login.html收藏,这时访问项目就会出现404,因此还需要配置不管访问什么页面都要跳转到维护页面,可以在Nginx里设置静态页面设置强制跳转
2.具体配置内容
server {
server_name localhost;
listen 80;
location / {
root /data/code/weihutongzhi;
index index.html;
}
if ($request_uri !~ "^/index.html$") {
rewrite ^(.*) http:/urlxxx/index.html permanent;
}
}
server {
listen 443;
server_name localhost;
ssl_certificate xxx.pem;
ssl_certificate_key xxx.key;
location / {
root /data/code/weihutongzhi;
index index.html;
}
if ($request_uri !~ "^/index.html$") {
rewrite ^(.*) https://urlxxx/index.html permanent;
}
}