Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

desiredpersona
desiredpersona
4,481 Points

Wordpress Maintenance Mode

hello,

I am currently developing a live wordpress site that is ranking number 1 in google for its exact match keyword. (Not much competition for keyword.)

I want to show a landing page for visitors without hurting my homepage ranking.

I turned on wordpress maintenance mode without using a plugin by adding the following code to a .maintenance file and putting it in wordpress root.

<?php function is_user_logged_in() { $loggedin = false; foreach ( (array) $COOKIE as $cookie => $value ) { if ( stristr($cookie, 'wordpress_logged_in') ) $loggedin = true; } return $loggedin; } if ( ! stristr($_SERVER['REQUEST_URI'], '/wp-admin') && ! stristr($_SERVER['REQUEST_URI'], '/wp-login.php') && ! is_user_logged_in() ) $upgrading = time(); ?>

Then in the wp-content directory i added maintenance.php file so i can style the landing page.

<code> <?php $protocol = $_SERVER["SERVER_PROTOCOL"]; if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol ) $protocol = 'HTTP/1.0'; header( "$protocol 503 Service Unavailable", true, 503 ); header( 'Content-Type: text/html; charset=utf-8' ); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <body> <h1>Briefly unavailable for scheduled maintenance. Check back in a minute.</h1> </body> </html> <?php die(); ?>

</code>

Is there a better way to do this from an SEO point of view?

2 Answers

Ian Carroll
Ian Carroll
1,901 Points

While I'm not an SEO expert, putting your site in that mode shouldn't hurt your ranking.