Do you want to come to
Well House Manor as a base to see Wiltshire or for
a course? If it's you're first visit you'll want to find us on a map - and we have a map at
http://www.wellho.net/demo/gmap.php which you can zoome to five levels at the click of a button and do other smart things with. And that map is Google powered.

But not everyone arrives at that page via www.wellho.
net; you'll find that it's mirrored on www.wellho.
co.uk, for example, and a handful of other domains. And occasionally we find people arriving by IP address. And if they did, they got not a map but an error message about the Google key being wrong.
Rather than register and maintain a series of keys, I have modified the map page to redirect visitors to the www.wellho.net site if they've arrived from elsewhere, by checking which server they've called up within my PHP and sending out a short redirect page if they're on a subsidiary domain. The extra code is as follows:
if ($_SERVER[SERVER_NAME] != "www.wellho.net") {
print <<<DONE
<html>
<head>
<meta http-equiv="refresh" content="6;url=http://www.wellho.net/demo/gmap.php">
</head>
<body>
This demonstration relies on a Google key on our main server (www.wellho.net)
but you are visiting from a different domain. You will be redirected shortly
(if you are not, please follow
<a href=http://www.wellho.net/demo/gmap.php>this link)</a>.
</body>
</html>
DONE;
exit(0);
}
Literally, that's saying "if you are not on the main server, please move on to that server after showing this page for 6 seconds". This is known as client pull - it relies on the browser to request the new page - so it's good practise to provide an onwards link too, just in case the browser can't / won't do as it has been directed.
Try out this, and the map - here are links to
the page that redirects, and to
the working page. If you're interested in the map iteself and how we generate that, you can see our source code
here, and we'll teach you how to write code like this on our
PHP techiques Workshop and
Intermediate PHP training weekend.
Index under "This web site needs a different Google Maps API key. A new key can be generated at http://code.google.com/apis/maps."
(written 2010-03-13)
Associated topics are indexed under
H309 - PHP - Maps, Graphics and Geographics [3584] QR codes - graphics images that provide quick phone links - (2012-01-18)
[3536] UK Mapping Data - and more to come - under government Open Data measures - (2011-12-03)
[3447] Needle in a haystack - finding the web server overload - (2011-09-18)
[3211] Computer Graphics in PHP - World (incoming data) to Pixel (screen) conversion - (2011-03-24)
[3197] Finding and diverting image requests from rogue domains - (2011-03-08)
[3133] An image from a website that occasionally comes out as hyroglyphics - (2011-01-14)
[3027] Server logs - drawing a graph of gathered data - (2010-11-03)
[2939] Protecting your images from use out of context - (2010-08-29)
[2729] Uploading a document or image to its own URL via a browser - (2010-04-18)
[2583] Reducing image size on digital photos - PHP - (2010-01-17)
[2390] Dynamic / changing images on your web page - (2009-09-01)
[2361] Geocoding - converting address to latitude / Longitude with PHP via Google - (2009-08-14)
[2343] World Flags in your PHP pages - (2009-08-10)
[1956] Images for Christmas - (2008-12-21)
[1923] Making it all worthwhile - (2008-12-04)
[1756] Ever had One of THOSE mornings? - (2008-08-16)
[1752] Dynamic maps / geographics in PHP - (2008-08-13)
[1734] All around the world? - (2008-08-03)
[1724] addslashes v mysql_real_escape_string in PHP - (2008-07-27)
[1628] Gant charts - drawing them with a PHP script - (2008-05-03)
[1391] Ordnance Survey Grid Reference to Latitude / Longitude - (2007-10-14)
[1390] Converting from postal address to latitude / longitude - (2007-10-13)
[1389] Controlling and labelling Google maps via PHP - (2007-10-13)
[1194] Drawing hands on a clock face - PHP - (2007-05-19)
[1104] Drawing dynamic graphs in PHP - (2007-03-09)
[937] Display an image from a MySQL database in a web page via PHP - (2006-11-22)
[665] PHP Image viewing application - (2006-04-01)
[563] Merging pictures using PHP and GD - (2006-01-13)
[320] Ordnance Survey - using a 'Get a map' - (2005-05-22)
W502 - Web and Intranet - HTML Document Anatomy [3563] How big is a web page these days? Does the size of your pages matter? - (2011-12-26)
[3517] Tags used in writing this blog - (2011-11-12)
[2246] What difference does using the XHTML standard really make? - (2009-06-18)
[1811] Alternative URLs using % symbol encoding - (2008-09-27)
[1463] All the special characters in HTML ... - (2007-12-07)
[1431] Getting the community on line - some basics - (2007-11-13)
[1187] Updating a page strictly every minute (PHP, Perl) - (2007-05-14)
[1160] HTML - example of a simple web page - (2007-04-24)
[993] Positioning with Cascading Style Sheets - (2006-12-16)
[857] Strikingly busy - (2006-09-06)
Some other Articles
How to build a test harness into your PHPReaching out to the community - a good case for supportBlowing out the winter cobwebsChanging TimesRedirecting to your main domain for correct security keysMake and makefiles - a commented example to help you learnMultiple Inheritance in C++ - a complete exampleDear Planners, please provide viable alternativesMelksham - Carnival, Party in the Park, and Spot the OddityPointers to Pointers to Pointers - what is the point?