How to stop google indexing my staging site -

WordPress hosting done right. done fast. done secure


How to stop google indexing my staging site

If you’re not careful, google will index your staging site, causing reduced SEO, plus other issues. Here’s how to stop it. Put this code in your header.php in your theme, either before the <title> tag, or after the </tilte> tag.

if( strpos ($_SERVER['HTTP_HOST'] , 'staging') > -1 ) {
echo '<meta name="robots" content="noindex,nofollow">' ;

So how does it work ? it looks for the word ‘staging’ in the server name, and displays the noindex rule for google. But when your site is pushed to production, and loses the staging in the server name, the noindex is also removed.

By on December 29th, 2015 ,

Email or call, and we can arrange a time to chat call 0412927156 or CONTACT US TODAY!