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

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


503 Temporarily Unavailable, with trigger

RewriteEngine OnRewriteCond %{ENV:REDIRECT_STATUS} !=503RewriteCond "/srv/www/example.com/maintenance.trigger" -fRewriteRule ^(.*)$ /$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!


You could use mod_rewrite:

RewriteEngine onRewriteCond %{ENV:REDIRECT_STATUS} !=503RewriteRule !^/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.


@temoto

To specify a 503 for bots and a maintenance page for humans, try the following

RewriteEngine onRewriteBase /#for bots such as googleRewriteCond %{HTTP_USER_AGENT} ^.*(Googlebot|Googlebot|Mediapartners|Adsbot|Feedfetcher|bingbot)-?(Google|Image)? [NC]RewriteCond %{ENV:REDIRECT_STATUS} !=503RewriteRule !^/down/for/maintenance$ %{DOCUMENT_ROOT}down/for/maintenance [L,R=503]#for humansRewriteCond %{REMOTE_HOST} !^1\.1\.1\.1RewriteCond %{REQUEST_URI} !^/maint.html [NC]RewriteRule .* /maint.html [R=302,L]