track ip addresses, phone numbers, etc

Returning HTTP 503 using PHP (maintenance page)

Published on 07 February 2015

Returning HTTP 503 using PHP (maintenance page)

If you need to create an "under maintenance" page in PHP without getting Googlebot to index it, create a PHP script.

Let's call it maintenancee503.php and place in the home directory, in this case assume under /www/ARUL/. Add these lines:


header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 3600');

Without using PHP - Apache's httpd.conf file

If you have access to Apache's httpd.conf file, you can edit it to output HTTP 503 code to all requests.

First, create a simple or custom file and call it maintenance503.html under /www/ARUL.

Configure Apache to forward all requests to this script maintenance503.php.

In Apache, this is what you would typically do. Edit httpd.conf or .htaccess file and include these lines:

RewriteEngine on
RewriteCond %{ENV:REDIRECT_STATUS} !=503
RewriteRule !^maintenance503.html$ %{DOCUMENT_ROOT}/maintenance503.html [L,R=503]

Make sure the Error 503 line contains this:

ErrorDocument 503 /www/ARUL/maintanence503.html

Then restart Apache. If editing .htaccess, you don't need to restart Apache.

Created on 07 February 2015

TAGS: php, http, 503

Affiliate Disclosure: Some of the links to products on this blog are affiliate links. It simply means, at no additional cost to you, we’ll earn a commission if you click through and buy any product.