How to make a redirect 503 (maintenance code) on every site, but leave only one URL that can be accessed?
Server: Linux (Apache) with PHP 5.5 and MySQL.
How to make a redirect 503 (maintenance code) on every site, but leave only one URL that can be accessed?
Server: Linux (Apache) with PHP 5.5 and MySQL.
Put in .htaccess
(or apache configuration):
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/caminho/permitido.html
RewriteRule .* /erro503.php
The !
no RewriteCond
means deny, that is, the condition is that the path is not indicated below, so that RewriteRule
takes action.
This is the script erro503.php
:
<?php
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 3600');
?>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>Serviço Temporariamente Indisponível</title>
</head><body>
<h1>Serviço Temporariamente Indisponível</h1>
<p>(Ponha sua explicacao aqui).</p>
</body></html>
change the value of Retry-After
to the desired time in seconds (pro forma, in practice I think that agent does not use this value)
header Status
is only required if you use PHP as CGI.