Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put Apache website to 503 "temporary down"?

RFC2616, 503 Service Unavailable

The server is currently unable to handle the request due to a temporary overloading or maintenance of the server

How to configure Apache 2.2 to serve particular name based virtualhost 503 code with custom HTML page?

like image 585
temoto Avatar asked Mar 07 '09 20:03

temoto


2 Answers

503 Temporarily Unavailable, with trigger

RewriteEngine On RewriteCond %{ENV:REDIRECT_STATUS} !=503 RewriteCond "/srv/www/example.com/maintenance.trigger" -f RewriteRule ^(.*)$ /$1 [R=503,L] 

If the maintenance.trigger file exists, Apache will serve up a 503 Service Unavailable response. To serve up a custom "down for maintenance" page, use ErrorDocument to specify the file, like so:

ErrorDocument 503 /503_with_cats.html 

Enjoy!

like image 190
captainpete Avatar answered Sep 22 '22 07:09

captainpete


You could use mod_rewrite:

RewriteEngine on RewriteCond %{ENV:REDIRECT_STATUS} !=503 RewriteRule !^/down/for/maintenance$ %{DOCUMENT_ROOT}down/for/maintenance [L,R=503] 

The RewriteCond directive makes sure that no additional internal error occurs when redirecting to a custom error document.

like image 28
Gumbo Avatar answered Sep 20 '22 07:09

Gumbo