7
How to make a 503 redirect (maintenance code) throughout the site, but leave only one URL with access?
Server: Linux (Apache) with PHP 5.5 and Mysql.
7
How to make a 503 redirect (maintenance code) throughout the site, but leave only one URL with access?
Server: Linux (Apache) with PHP 5.5 and Mysql.
8
Put in the .htaccess
(or apache configuration):
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/caminho/permitido.html
RewriteRule .* /erro503.php
To !
in the RewriteCond
means denial, i.e., the condition is that the path nay is indicated below, so that the RewriteRule
take 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
for the desired time in seconds (pro-form, in practice I think no agent uses that value)
the header Status
only if you use PHP as CGI.
Got Bacco. In case then allowed.html will be the only accessible, correct?
Exactly. Test and tell the result, if we need to adjust.
Browser other questions tagged php htaccess redirecting
You are not signed in. Login or sign up in order to post.
Linux Server (Apache) - PHP 5.5 and Mysql.
– Marcony Felipe