When you’re deploying updates or migrating entire sites, you probably used a maintenance screen before: a simple screen telling the visitor that there is some major stuff going on on the server and that the site will be back online in a few moments.
It’s important that you don’t lose any precious SEO-value of your site when your sites displays this page. To prevent this from happening, we simply can tell the crawler that is attempting to index our website that we’re currently in maintenance mode. How? With response code 503:
503 Service Unavailable
The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay. If known, the length of the delay MAY be indicated in a Retry-After header. If no Retry-After is given, the client SHOULD handle the response as it would for a 500 response.
How would this look like in a PHP script? Well…
<?php $protocol = $_SERVER["SERVER_PROTOCOL"];
header("$protocol 503 Service Unavailable", true, 503);
header("Retry-After: 3600"); ?><!doctype html>
... etc ...
The Retry-After header sets a number of seconds after which the crawler can make a new attempt to index the site. Please note that if this header is not set, the client should (no guarantee here) as a 500 internal server error.
How would you rate this article?
★ ★ ★ ★ ★