diff -urNb sapphire/core/control/RootURLController.php ../silverstripe/sapphire/core/control/RootURLController.php
--- sapphire/core/control/RootURLController.php	2007-01-15 20:18:30.000000000 +0100
+++ ../silverstripe/sapphire/core/control/RootURLController.php	2007-05-10 09:59:53.668632648 +0200
@@ -5,16 +5,18 @@
  */
 class RootURLController extends Controller {
 	function index() {
-		
 		$host = $_SERVER['HTTP_HOST'];
 		$host = str_replace('www.','',$host);
-		
 		$SQL_host = Convert::raw2sql($host);
-		
-		$destPage = DataObject::get_one("SiteTree", "HomepageForDomain = '$SQL_host'");
-		
-		if($destPage) Director::redirect($destPage->Link());
-		else Director::redirect("home/");
+		$homePageOBJ = DataObject::get_one("SiteTree", "HomepageForDomain = '$SQL_host'");
+		//die(print_r($homePageOBJ));
+		if($homePageOBJ) {
+		    $hpdom = $homePageOBJ->URLSegment;
+			Director::direct($hpdom);
+		} else {
+			$hpdom = '/';
+			Director::direct('home/');
+		}
 	}
 }
 
diff -urNb sapphire/main.php ../silverstripe/sapphire/main.php
--- sapphire/main.php	2007-05-09 04:58:25.000000000 +0200
+++ ../silverstripe/sapphire/main.php	2007-05-10 09:59:37.051594148 +0200
@@ -16,7 +16,7 @@
 	if($_GET) stripslashes_recursively($_GET);
 	if($_POST) stripslashes_recursively($_POST);
 }
-if(isset($_REQUEST['trace'])) apd_set_pprof_trace();
+if($_REQUEST['trace']) apd_set_pprof_trace();
 
 
 require_once("core/ManifestBuilder.php");
@@ -88,8 +88,30 @@
 
 // Direct away - this is the "main" function, that hands control to the apporopriate controllerx
 
+$host = $_SERVER['HTTP_HOST'];
+$host = str_replace('www.','',$host);
+$SQL_host = Convert::raw2sql($host);
+$homePageOBJ = DataObject::get_one("SiteTree", "HomepageForDomain = '$SQL_host'");
+if($homePageOBJ) {
+	$hpdom = $homePageOBJ->URLSegment;
+} else {
+	$hpdom = '/';
+}
+
+$surl = split('/',$url);
 $dir = new Director();
-$dir->direct($url);
+
+if (($surl[1] != $hpdom) && ($surl[1] != 'home'))  { 
+	$dir->direct($url);
+} elseif ($surl[1] == $hpdom && $surl[2] != '') {
+	$dir->direct($url);
+} elseif ($surl[1] == 'home' && $surl[2] != '') {
+	$dir->direct($url);
+} elseif ($surl[1] == 'home') {
+	$dir->redirect($baseURL);
+} elseif ($surl[1] == '') {
+	$dir->direct($url);
+}        
 
 if(isset($_GET['debug_profile'])) {
 	Profiler::unmark('all_execution');

