Htaccess Temporary Redirect Visitors During Maintenance

in SEO

I have previously informed to you, for the second time my website has been suspended by hosting providers. So I need to tell this situation to the Google bot/spider so my website is not damaged in the Google Search Engine or other search engines. The question is: How to redirect visitors during site maintenance?

I need send Google BOTS/spider to a 503 and humans to maintenance page for temporary.  Here are some very useful information to make these questions answered and realized

Temporary Site Redirect for Visitors During Site Updates
Here you can read complete guide required for redirecting visitors temporarily during periods of site maintenance. Temporary site redirect via htaccess, Temporary site redirect via PHP

Instruct Search Engines to Come Back to Site After You Finish Working on it
Here you can read SEO knowledge, 503 information, 503 Header with PHP or Perl CGI, etc

I tried to use code from askapache to send BOTS a 503 and humans to error page, like this:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} ^.*(Googlebot|Googlebot|Mediapartners|Adsbot|Feedfetcher)-?(Google|Image)? [NC]
RewriteCond %{REQUEST_URI} !^/cgi-bin/error/503\.php [NC]
RewriteRule .* /cgi-bin/error/503.php
RewriteCond %{REMOTE_HOST} !^1\.1\.1\.1
RewriteCond %{REQUEST_URI} !^/cgi-bin/error/404\.php [NC]
RewriteRule .* /under-development.html [R=302,L]

But, found an error when I tried to access my website :
Problem loading page: The page isn’t redirecting properly

Finally I found a solution from this page: Temporary Redirect All Visitors

I mixed those codes and my problem solved. My website has been able to redirect search engine bots to 503 page (I hope) and human redirect to maintenance page. Here they are files and code used by my website during maintenance/developed, exactly suspended by hosting provider :p

My htaccess code:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} ^.*(Googlebot|Googlebot|Mediapartners|Adsbot|Feedfetcher)-?(Google|Image)? [NC]
RewriteCond %{REQUEST_URI} !^/cgi-bin/error/503\.php [NC]
RewriteRule .* /cgi-bin/error/503.php
RewriteCond %{REMOTE_HOST} !^1\.1\.1\.1
RewriteCond %{REQUEST_URI} !/under-development\.html$
RewriteRule .* /under-development.html [R=302,L]

My 503.php:

<?php
ob_start();
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 3600');
header('X-Powered-By:');
?><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>503 Service Temporarily Unavailable</title>
</head><body>
<h1>Service Temporarily Unavailable</h1>
<p>The server is temporarily unable to service your
request due to maintenance downtime or capacity
problems. Please try again later.</p>
</body></html>

CMIIW

Use the social buttons below to add it on your favorite social sites to get the latest updates. Not sure about these options? Learn more about RSS and social bookmarking

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

Leave a Comment

Previous post:

Next post: