Jump to:

23489 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Down for maintence page in CMS

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 2721 Views
  • Mo
    Avatar
    Community Member
    508 Posts

    Down for maintence page in CMS Link to this post

    I seem to posting a lot in here at the moment...

    I was wondering if there is a way to create a "Down for maintenence" page through the CMS that would publish a html page (Just like ErrorPage does now)?

    Could I achieve this through a subclass of error page? Or is there a class that I can use to generate a html file from my own page class?

    Any help appreciated,

    Mo

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Down for maintence page in CMS Link to this post

    I would be interested in a solution to this as well.
    Usually I just add a rewrite rule in my .htaccess, before the SilverStripe rewrite rule. This then redirects to the "down for maintenance" page.
    So it actually reduces to un/commenting a line in the .htaccess.

    Changing it inside the CMS would be much nicer though.

  • Mo
    Avatar
    Community Member
    508 Posts

    Re: Down for maintence page in CMS Link to this post

    I was thinking along the lines of being able to content edit the page, rather than skipping the htaccess part... But that would be pretty handy as well

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Down for maintence page in CMS Link to this post

    Yeah. The following .htaccess usually does the trick (and you should be able to enter the cms still):

    ### SILVERSTRIPE START ###
    <Files *.ss>
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
    </Files>

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$

    # comment/uncomment the 2 lines to enable/disable the down for maintenance page
    RewriteCond %{REQUEST_URI} !/(Security/.+|admin).*$ [NC]
    RewriteRule .* downformaintenance.html [L,NC]

    RewriteCond %{REQUEST_URI} ^(.*)$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
    </IfModule>
    ### SILVERSTRIPE END ###

    Update Fixed the rewrite condition (added .*)

  • Mo
    Avatar
    Community Member
    508 Posts

    Re: Down for maintence page in CMS Link to this post

    Wouldn't it make more sense to use:

    RewriteCond %{REMOTE_ADDR} !^xxx\.xxx\.xxx\.xxx

    To allow pre defined IP addresses to view the site? That way you can check it properly setting changes live?

    Also, what markup do I need to use in this forum to get a code block? (edit: never mind, I found the 'Formatting Help' link)

    Mo

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Down for maintence page in CMS Link to this post

    Yes, that's even better if you got a fixed IP that is.

  • Mo
    Avatar
    Community Member
    508 Posts

    Re: Down for maintence page in CMS Link to this post

    Yes, I guess it would require a fixed IP... Luckily I have one in work .

    I guess another way would be to create a sub domain that points to the main site and then redirect that domain when the site is live and use it to access the site while it is down for maintenance? Shouldn't be to hard, you would just have to switch which rules you comment in your htaccess.

    Admittedly, I could be making this too complex, but it seems like an idea at least .

  • Radon
    Avatar
    Community Member
    11 Posts

    Re: Down for maintence page in CMS Link to this post

    You will want to send a HTTP 503 response as well, not a 200.
    Probably the easiest way is to use a separate docroot for a 503 page and just switch the vhost to let apache server that file instead of your SilverStripe installation. Conceptually:

    <?php
       header( "HTTP/1.0 503 Service Unavailable" );
    ?>
    <html>
       <head><title>Service Unavailable</title></head>
       <body>My 1337 site is currently unavailable due to maintainance. Please try again in a couple of minutes</body>
    </html>

    2721 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.