Last Updated: October 07, 2020
·
3.036K
· ekrembk

Maintenance header for SEO with PHP

No need for a detailed explanation. When your website is under construction, tell search engines to come back later. That's where we need 503. Here is the codes:

header( ( $_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.1' ? 'HTTP/1.1' : 'HTTP/1.0' ) . ' 503 Service Unavailable', true, 503 );
header( "Retry-After: 3600" );

3600 is the number of seconds for search engines to come back later.

1 Response
Add your response

If anyone want to be sure that Google respects 503 status code, you should check this link http://googlewebmastercentral.blogspot.com/2006/08/all-about-googlebot.html

over 1 year ago ·

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.

Security insights from Cside