I have a number of domain names and previously blogged on how to make Geeklog work on all of them.
I’ve decided now to concentrate on one domain name: julian-kuiters.id.au
There is already a number of links to my other domains, so I needed to configure Geeklog to redirect people to the new domain. I think that re-direct pages are pretty annoying, so I opted to use “HTTP/1.1 301 Moved Permanently” to indicate to browsers and search engines the new address.
After quite a few attempts at inserting the redirect code in the theme, I opted to place it in the lib-common.php file.
The basic code to redirect any connects not on my primary domain is:
if ($_SERVER['SERVER_NAME'] != 'www.julian-kuiters.id.au')
{
header("HTTP/1.1 301 Moved Permanently"); // Convert to GET
header("Location: http://www.julian-kuiters.id.au" . $_SERVER['REQUEST_URI']);
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
}
And I inserted it into the function COM_siteHeader of lib-common.php
function COM_siteHeader( $what = 'menu', $pagetitle = '', $headercode = '' )
{
global $_CONF, $_TABLES, $_USER, $LANG01, $LANG_BUTTONS, $LANG_CHARSET,
$LANG_DIRECTION, $_IMAGE_TYPE, $topic, $_COM_VERBOSE;
//jkuiters 20070420
if ($_SERVER['SERVER_NAME'] != 'www.julian-kuiters.id.au')
{
header("HTTP/1.1 301 Moved Permanently"); // Convert to GET
header("Location: http://www.julian-kuiters.id.au" . $_SERVER['REQUEST_URI']);
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
}
// If the theme implemented this for us then call their version instead.
$function = $_CONF['theme'] . '_siteHeader';
As you can now see, the same url on different domains automatically takes you to the correct site.

















