Show maintenance page when .lock file is present

2019-09-08 16:36发布

问题:

guys!

I'm trying to figure out, how to show maintenance only when .lock file is present. The problem is, that I'm using symfony2 for my project. And I can't get it work.

I'm trying to do something like this (nginx config):

location / {
   if (-f $document_root/.lock) {
     rewrite ^ /maintenance last;
     break;
   }
   index app.php;
   try_files $uri @rewriteapp;
}

location @rewriteapp {
  rewrite ^(.*)$ /app.php/$1 last;
}

location ~ ^/.*\.php(/|$) {
  fastcgi_split_path_info ^(.+\.php)(/.*)$;
  include fastcgi_params;
}

The page is shown, but all static files are redirected to /maintenance too. Please help!

回答1:

Move the if block inside the rewriteapp location.



标签: symfony nginx