Skip to content

Commit

Permalink
Return a 503 status code along with the maintenance page. This should…
Browse files Browse the repository at this point in the history
… prevent search engines from indexing your maintenance page, make life easier on API consumers, enable AJAX requests to correctly deal with the site being down, and so on.

Credit to @chrisk for the idea. See http://shiftcommathree.com/articles/make-your-rails-maintenance-page-respond-with-a-503 for more information.
  • Loading branch information
morgancurrie committed Mar 29, 2011
1 parent b070937 commit 10de3f2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/moonshine/manifest/rails/templates/passenger.vhost.erb
Expand Up @@ -183,9 +183,11 @@
<%= configuration[:passenger][:maintenance_rewrite] %>
<% else %>
# Check for maintenance file and redirect all requests
ErrorDocument 503 /system/maintenance.html
RewriteCond %{REQUEST_URI} !\.(css|jpg|png|gif)$
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteRule ^.*$ /system/maintenance.html [L]
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ - [R=503,L]
<% end %>

# Rewrite index to check for static
Expand Down Expand Up @@ -399,9 +401,11 @@
<%= configuration[:passenger][:maintenance_rewrite] %>
<% else %>
# Check for maintenance file and redirect all requests
ErrorDocument 503 /system/maintenance.html
RewriteCond %{REQUEST_URI} !\.(css|jpg|png|gif)$
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteRule ^.*$ /system/maintenance.html [L]
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ - [R=503,L]
<% end %>

# Rewrite index to check for static
Expand Down

0 comments on commit 10de3f2

Please sign in to comment.