I require a website to return a 503, whilst under construction.
I am pointing visitors to a friendly 'Coming Soon' page, but Google Webmaster Tools reports "Googlebot can't access your site".
This is the current rule in .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
# Allow Access Locally
RewriteCond %{REMOTE_ADDR} !^127.0.0.1
# Prevent 503 for Maintenance Page
RewriteCond %{REQUEST_URI} !/maintenance [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
# Show Friendly 503
RewriteRule .* http://www.example.com/maintenance/index.php [R=503,L]
</IfModule>
It works well for visitors, but how can I amend the rule to ensure Google understands the 503?
In the header of the maintenance file I have:
<?php
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: Wed, 18 Jun 2014 01:00:00 GMT');
?>
I presume Google is trying to get to robots.txt. Should this be excluded from the 503 instruction?
Thank you
Replace this line:
RewriteRule .* http://www.example.com/maintenance/index.php [R=503,L]
With:
RewriteRule !^503\.php$ /503.php [L,NC]
And inside /503.php
add http_response_code(503)
like this:
<?php
http_response_code(503);
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: Wed, 18 Jun 2014 01:00:00 GMT');
?>