I've to do some big works to my website, so I've to put it offline for some hours, but I don't want to lose my rank in google. I've read this tutorial: http://www.branded3.com/blogs/handle-googlebot-during-site-downtime/ This is the correct procedure, right?

I've also another question. Where should I put this code?

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

In the index.php, ora in a new page named errorpage.php in the root? Google will find this automatically?


  • 1
    I'm not sure about the Status header - that's non-standard and unnecessary IMO. See also these other questions: How do I temporarily disable a website? and How to set restrictions on my website?
    – MrWhite
    May 4 '14 at 11:11
  • 1
    @w3d +1 for the links (I think this one is a duplicate), but the Status header is required for fastcgi
    – Yogu
    May 4 '14 at 13:00
  • Do you mean that I can remove this line? header("Status: 503 Service Temporarily Unavailable"); I'm sorry but I really don't have idea about how these things work. May 4 '14 at 21:16
  • @Yogu Thanks for the info regarding the Status header and FastCGI. However, I think if PHP is configured properly then this should be unnecessary (PHP should convert it as reqd)? See this SO question: stackoverflow.com/questions/8828275/…
    – MrWhite
    May 7 '14 at 22:44
  • @daimpa: In theory, yes. However, as Yogu mentioned, this can depend on your server. Both the HTTP/1.1... and Status: lines do the same thing but in different server environments. Ideally, you should only need the first one (and PHP should convert it as reqd). (You should still use the Retry-After header.)
    – MrWhite
    May 7 '14 at 22:49

It depends on your application. If your application has a front controller like WordPress, then you can use index.php to make the complete site offline, since all requests go via index.php.

If your application consists of individual PHP files, then you have to put the code to each file.

  • If you have a collection of files (the 2nd part of this answer), you can use a .htaccess to rewrite all pages to your temp-unavailable.php
    – Martijn
    May 4 '14 at 11:37
  • So, if I put this on my .htaccess in the root, I've done everything correctly? Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{HTTP_USER_AGENT} ^.*google.* [NC] RewriteRule .* /errorpage.php May 4 '14 at 21:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.