nginx维护页面-全部URL指向同一个页面
nginx维护页面处理-全部URL指向同一个页面
一般来说nginx的维护页面需要把所有访问本站的链接全部重定向到某个指定页面
方法一 rewrite
rewrite ^(.*)$ /maintain.html break;
注意这句后面如果有重定向等语句,那么后面执行的重定向等语句需要全部注释掉
方法二 使用状态码
location /{
return 503;
}
注意其他location优先级高的匹配均需要注释掉
error_page 503 /maintain.html;
方法三
server {
listen 4008;
server_name localhost;
charset utf-8;
#access_log logs/host.access.log main;
location / {
root /var/webroot/maintain/;
index index.html index.htm;
}
# redirect server error pages to the static page /50x.html
#
error_page 404 405 500 502 503 504 /index.html;
location = /index.html {
root /var/webroot/maintain/;
}
}
转载于:https://blog.51cto.com/tianshili/1905321
更多推荐


所有评论(0)