1

I'm trying to disable the website I deployed on my test server with Capifony.

The maintenance.html file goes up, everything's ok with the web:disable/enable commands.

My only problem is how to detect the maintenance file, and redirect to it using the .htaccess file provided by Symfony.

(I thought of detecting the maintenance file in the app_*.php scripts, but not only it feels hacky, it wouldn't disable access to the other files in the web/ folder.)

Any advice is greatly appreciated.

ZeeCoder
  • 1,001
  • 9
  • 17

2 Answers2

1

You can disable access directly by rewrite rule in your webserver config. If maintenance.html file found redirect to it, or to another static page. For Apache's htaccess it will be something like this:

RewriteCond  %{DOCUMENT_ROOT}/web/maintenance.html  -f
RewriteRule  ^/(.+) /web/maintenance.html [QSA,L]  [L,QSA]
sampleNull
  • 126
  • 1
  • 8
0

I havn't tested it yet but the Capifony lib features this snippet:

ErrorDocument 503 /#{maintenance_basename}.html
RewriteEngine On
RewriteCond %{REQUEST_URI} !\.(css|gif|jpg|png)$
RewriteCond %{DOCUMENT_ROOT}/#{maintenance_basename}.html -f
RewriteCond %{SCRIPT_FILENAME} !#{maintenance_basename}.html
RewriteRule ^.*$ - [redirect=503,last]

https://github.com/everzet/capifony/blob/master/lib/symfony2/web.rb

webDEVILopers
  • 1,886
  • 1
  • 21
  • 35
  • Another example for Apache and Capistrano: http://nebulab.it/blog/maintenance-page-with-apache-and-capistrano – webDEVILopers Jan 15 '15 at 14:13
  • Since I asked this question, I actually found a really good solution: https://github.com/lexik/LexikMaintenanceBundle – ZeeCoder Jan 15 '15 at 14:18
  • That's a nice one too, thanks! BTW: I'm trying my first deploy with web:disable and Capifony and Capifony tries to upload the maintenance.html file from my latest release instead of creating a new one. Did this ever happen to you or did you provide the file in your repository and only change the htaccess for your production server? – webDEVILopers Jan 15 '15 at 14:22
  • I don't really remember to be honest, I quickly switched to the above mentioned method. – ZeeCoder Jan 15 '15 at 15:38