Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Down for maintence page in CMS


Go to End


13 Posts   5179 Views

Avatar
Mo

Community Member, 541 Posts

10 June 2009 at 3:02am

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

Avatar
bummzack

Community Member, 904 Posts

10 June 2009 at 4:41am

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.

Avatar
Mo

Community Member, 541 Posts

10 June 2009 at 5:25am

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 :)

Avatar
bummzack

Community Member, 904 Posts

10 June 2009 at 6:16am

Edited: 10/06/2009 7:18am

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 .*)

Avatar
Mo

Community Member, 541 Posts

10 June 2009 at 8:50pm

Edited: 10/06/2009 8:52pm

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

Avatar
bummzack

Community Member, 904 Posts

10 June 2009 at 9:01pm

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

Avatar
Mo

Community Member, 541 Posts

10 June 2009 at 10:05pm

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 :).

Avatar
Radon

Community Member, 11 Posts

10 June 2009 at 11:44pm

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>

Go to Top