VPS侦探论坛

 找回密码
 注册
查看: 3722|回复: 3

[Apache] 怎么让部分页面不显示自定义维护页面?

[复制链接]
发表于 2019-3-14 11:30:03 | 显示全部楼层 |阅读模式

在网站的根目录上传了一个自定义的503页面文件夹,包含html,css,和图片。然后希望部分页面正常显示,其余页面都显示这个503维护页面。我的nginx部分配置:
  1. location / {
  2. # 跨域设置
  3. add_header 'Access-Control-Allow-Origin' $http_origin;
  4. add_header 'Access-Control-Allow-Credentials' 'true';
  5. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  6. add_header 'Access-Control-Allow-Headers' 'DNT,Accept,Origin,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  7. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
  8. if ($request_method = 'OPTIONS') {
  9.             add_header 'Access-Control-Max-Age' 1728000;
  10.             add_header 'Content-Type' 'text/plain; charset=utf-8';
  11.             add_header 'Content-Length' 0;
  12.             return 204;
  13. }

  14. # 维护页面

  15. set $flag 0;
  16. if ($request_uri !~ "(/houtai/).*$"){
  17.       set $flag "${flag}1";
  18. }
  19. if ($request_uri !~ "/503/503.html$" ){
  20.       set $flag "${flag}2";
  21. }
  22. if ($request_uri !~ "(/503/css/.*)$" ){
  23.       set $flag "${flag}3";
  24. }
  25. if ($request_uri !~ "(/503/images/.*)$" ){
  26.       set $flag "${flag}4";
  27. }

  28. if (-f $document_root/503/503.html) {
  29.       set $flag "${flag}5";
  30. }

  31. if ($request_uri !~ "(/zt/).*$"){
  32.       set $flag "${flag}6";
  33. }

  34. if ($flag = "0123456") {
  35.            return 503;
  36.          }

  37. }

  38. error_page 503 @maintenance;
  39.     location @maintenance {
  40.     rewrite ^(.*)$ /503/503.html break;
  41. }
复制代码


希望访问的URL包含houtai,zt和503的时候显示正常,然后其他的访问码是503。
实际发现,部分URL应该是显示维护页面但是却是正常显示了,请问大佬,我这里应该怎么弄?
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2019-3-14 13:26:41 | 显示全部楼层


可能匹配规则上有问题
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2019-3-14 13:29:45 | 显示全部楼层

回复 2# 的帖子


军哥 你看规则应该怎么弄呢 排除 houta 503  zt 这三个目录
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2019-5-26 15:33:37 | 显示全部楼层



看看,学习一下
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-5-18 15:25 , Processed in 0.026435 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表