- Messages
- 764
- Reaction score
- 27
- Points
- 0
Here is a little trick I came up with some time ago to compensate for flaky hosting, thankfully have not needed it for a while but some of you may find this useful for basic sites. However if you are heavily dependant on databases then it gets a lot more complicated as these may need to be synchronised periodically or even frequently if you have a forum or chatroom.
How it Works:
Basically you employ a Google Free Site as your main landing site, this runs a simple bit of javascript wrapped in XML. A quick check is performed to see if your actual site is up and running and if not performs a redirect to an alternate URL. This can either be a mirror copy of your site or just an error page, hosted on a different server/provider.
The check to see if a domain is up and running is very basic, using a simple request for an image. Should this image request fail it sends an error back to the javascript that asks for that same image from the next mirror site in turn and so on till it finds a working server.
When it finds one that works it then performs a redirect to the active host. Finally you need to add 'frame breakout' to the landing URL page in order to destroy the Google Site Iframe and hey presto your done.
Here's the basic XML code to be attached to a google web site page, modify to suit.
Limitations:
Google is of course just like any other web host and can suffer from outages themselves but for the most part are regarded as very stable and ideal for this purpose.
How it Works:
Basically you employ a Google Free Site as your main landing site, this runs a simple bit of javascript wrapped in XML. A quick check is performed to see if your actual site is up and running and if not performs a redirect to an alternate URL. This can either be a mirror copy of your site or just an error page, hosted on a different server/provider.
The check to see if a domain is up and running is very basic, using a simple request for an image. Should this image request fail it sends an error back to the javascript that asks for that same image from the next mirror site in turn and so on till it finds a working server.
When it finds one that works it then performs a redirect to the active host. Finally you need to add 'frame breakout' to the landing URL page in order to destroy the Google Site Iframe and hey presto your done.
Here's the basic XML code to be attached to a google web site page, modify to suit.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="test1" />
<Content type="html"><![CDATA[
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
var fields1="http://www.mySite_1/"; //primary site
var fields2="http://www.mySite_2/"; //secondary
var fields3="http://www.mySite_3/"; //tertiary
function redir1(com)
{ // read the command attribute
if (com == 1)sp=0; // check primary & set status : 0 = offline
if (com == 2)ss=0; // check secondary
if (com == 3)st=0; // check tertiary
if (com = "dump"){ // read the command attribute
//
winloc = fields1; // sets default primary site
if (sp == 0)winloc=fields2; // if primary offline redirect to secondary site
if (sp == 0 && ss == 0)winloc=fields3; // if primary and secondary offline redirect to tertiary site
window.location= winloc; // perform redirect
}// end dump
}// eof
</script>
</head>
<body>
<img src="http://www.mySite_1/test.gif" onerror="redir1(1)"> <!-- primary site check -->
<img src="http://www.mySite_2/test.gif" onerror="redir1(2)"> <!-- secondary site check -->
<img src="http://www.mySite_3/test.gif" onerror="redir1(3)"> <!-- tertiary site check -->
<script type="text/javascript">redir1(dump);</script> <!-- initiate redirect -->
</body>
</html>
]]></Content>
</Module>
Limitations:
Google is of course just like any other web host and can suffer from outages themselves but for the most part are regarded as very stable and ideal for this purpose.