diff --git a/interface/lib/classes/auth.inc.php b/interface/lib/classes/auth.inc.php
index 0315ed9aa62ab79682cec462c37d3b3fc765e4d1..20094cf7606047cce00db744b5d95fb626edd9f2 100644
--- a/interface/lib/classes/auth.inc.php
+++ b/interface/lib/classes/auth.inc.php
@@ -89,10 +89,9 @@ class auth {
 		if(!$this->client_limits)
 			return -1;
 		
-		if(isset($this->client_limits['limit_'.$limitname]))
+		if(isset($this->client_limits['limit_'.$limitname])) {
 			return $this->client_limits['limit_'.$limitname];
-		else
-			trigger_error('Wrong limit identifier');		
+		}		
 	}	
 	
 	//** This function removes a given group id from a given user.
diff --git a/interface/lib/plugins/sites_web_domain_plugin.inc.php b/interface/lib/plugins/sites_web_domain_plugin.inc.php
index b1e1689b8219052d7def850a4add739bd4b5489b..85a4cc04f7ef8cd9f8a2eb93db6e3978ac8f97db 100644
--- a/interface/lib/plugins/sites_web_domain_plugin.inc.php
+++ b/interface/lib/plugins/sites_web_domain_plugin.inc.php
@@ -9,6 +9,22 @@ class sites_web_domain_plugin {
 
 	var $plugin_name        = 'sites_web_domain_plugin';
 	var $class_name         = 'sites_web_domain_plugin';
+	
+	// TODO: This function is a duplicate from the one in interface/web/sites/web_domain_edit.php
+	//       There should be a single "token replacement" function to be called from modules and
+	//	 from the main code.
+	// Returna a "3/2/1" path hash from a numeric id '123'
+	function id_hash($id,$levels) {
+		$hash = "" . $id % 10 ;
+		$id /= 10 ;
+		$levels -- ;
+		while ( $levels > 0 ) {
+			$hash .= "/" . $id % 10 ;
+			$id /= 10 ;
+			$levels-- ;
+		}
+		return $hash;
+	}
 
     /*
             This function is called when the plugin is loaded
@@ -39,6 +55,11 @@ class sites_web_domain_plugin {
         $app->uses("getconf");        
         $web_config = $app->getconf->get_server_config(intval($page_form->dataRecord['server_id']),'web');            
         $document_root = str_replace("[website_id]",$page_form->id,$web_config["website_path"]);
+		$document_root = str_replace("[website_idhash_1]",$this->id_hash($page_form->id,1),$document_root);
+		$document_root = str_replace("[website_idhash_2]",$this->id_hash($page_form->id,1),$document_root);
+		$document_root = str_replace("[website_idhash_3]",$this->id_hash($page_form->id,1),$document_root);
+		$document_root = str_replace("[website_idhash_4]",$this->id_hash($page_form->id,1),$document_root);
+		
         // get the ID of the client
         if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {                    
             $client_group_id = $_SESSION["s"]["user"]["default_group"];
@@ -53,11 +74,20 @@ class sites_web_domain_plugin {
         // Set the values for document_root, system_user and system_group
         $system_user 				= $app->db->quote('web'.$page_form->id);
         $system_group 				= $app->db->quote('client'.$client_id);
-        $document_root 				= $app->db->quote(str_replace("[client_id]",$client_id,$document_root));
-        $php_open_basedir 			= str_replace("[website_path]",$document_root,$web_config["php_open_basedir"]);
+		
+		$document_root 				= str_replace("[client_id]",$client_id,$document_root);
+		$document_root				= str_replace("[client_idhash_1]",$this->id_hash($client_id,1),$document_root);
+		$document_root				= str_replace("[client_idhash_2]",$this->id_hash($client_id,2),$document_root);
+		$document_root				= str_replace("[client_idhash_3]",$this->id_hash($client_id,3),$document_root);
+		$document_root				= str_replace("[client_idhash_4]",$this->id_hash($client_id,4),$document_root);
+		$document_root 				= $app->db->quote($document_root);
+        
+		$php_open_basedir 			= str_replace("[website_path]",$document_root,$web_config["php_open_basedir"]);
         $php_open_basedir 			= $app->db->quote(str_replace("[website_domain]",$page_form->dataRecord['domain'],$php_open_basedir));
-        $htaccess_allow_override 	= $app->db->quote($web_config["htaccess_allow_override"]);
-        $sql = "UPDATE web_domain SET system_user = '$system_user', system_group = '$system_group', document_root = '$document_root', allow_override = '$htaccess_allow_override', php_open_basedir = '$php_open_basedir'  WHERE domain_id = ".$page_form->id;
+		
+		$htaccess_allow_override 	= $app->db->quote($web_config["htaccess_allow_override"]);
+        
+		$sql = "UPDATE web_domain SET system_user = '$system_user', system_group = '$system_group', document_root = '$document_root', allow_override = '$htaccess_allow_override', php_open_basedir = '$php_open_basedir'  WHERE domain_id = ".$page_form->id;
 		$app->db->query($sql);
 	}
 }              	
\ No newline at end of file
diff --git a/interface/web/sites/web_domain_edit.php b/interface/web/sites/web_domain_edit.php
index 83ba83faf82508592f63103b6ac39e3f4dbd115c..cf07f2a93c677ece180f9b345a1a6d651e96ee98 100644
--- a/interface/web/sites/web_domain_edit.php
+++ b/interface/web/sites/web_domain_edit.php
@@ -50,6 +50,19 @@ $app->load('tform_actions');
 
 class page_action extends tform_actions {
 
+	// Returna a "3/2/1" path hash from a numeric id '123'
+	function id_hash($id,$levels) {
+		$hash = "" . $id % 10 ;
+		$id /= 10 ;
+		$levels -- ;
+		while ( $levels > 0 ) {
+			$hash .= "/" . $id % 10 ;
+			$id /= 10 ;
+			$levels-- ;
+		}
+		return $hash;
+	}
+	
 	function onShowNew() {
 		global $app, $conf;
 
@@ -345,6 +358,10 @@ class page_action extends tform_actions {
 		$web_rec = $app->tform->getDataRecord($this->id);
 		$web_config = $app->getconf->get_server_config(intval($web_rec["server_id"]),'web');
 		$document_root = str_replace("[website_id]",$this->id,$web_config["website_path"]);
+		$document_root = str_replace("[website_idhash_1]",$this->id_hash($page_form->id,1),$document_root);
+		$document_root = str_replace("[website_idhash_2]",$this->id_hash($page_form->id,1),$document_root);
+		$document_root = str_replace("[website_idhash_3]",$this->id_hash($page_form->id,1),$document_root);
+		$document_root = str_replace("[website_idhash_4]",$this->id_hash($page_form->id,1),$document_root);
 
 		// get the ID of the client
 		if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {
@@ -360,7 +377,12 @@ class page_action extends tform_actions {
 		// Set the values for document_root, system_user and system_group
 		$system_user = $app->db->quote('web'.$this->id);
 		$system_group = $app->db->quote('client'.$client_id);
-		$document_root = $app->db->quote(str_replace("[client_id]",$client_id,$document_root));
+		$document_root = str_replace("[client_id]",$client_id,$document_root);
+		$document_root = str_replace("[client_idhash_1]",$this->id_hash($client_id,1),$document_root);
+		$document_root = str_replace("[client_idhash_2]",$this->id_hash($client_id,2),$document_root);
+		$document_root = str_replace("[client_idhash_3]",$this->id_hash($client_id,3),$document_root);
+		$document_root = str_replace("[client_idhash_4]",$this->id_hash($client_id,4),$document_root);
+		$document_root = $app->db->quote($document_root);
 		$php_open_basedir = str_replace("[website_path]",$document_root,$web_config["php_open_basedir"]);
 		$php_open_basedir = $app->db->quote(str_replace("[website_domain]",$web_rec['domain'],$php_open_basedir));
 		$htaccess_allow_override = $app->db->quote($web_config["htaccess_allow_override"]);
@@ -426,6 +448,10 @@ class page_action extends tform_actions {
 		$web_rec = $app->tform->getDataRecord($this->id);
 		$web_config = $app->getconf->get_server_config(intval($web_rec["server_id"]),'web');
 		$document_root = str_replace("[website_id]",$this->id,$web_config["website_path"]);
+		$document_root = str_replace("[website_idhash_1]",$this->id_hash($page_form->id,1),$document_root);
+		$document_root = str_replace("[website_idhash_2]",$this->id_hash($page_form->id,1),$document_root);
+		$document_root = str_replace("[website_idhash_3]",$this->id_hash($page_form->id,1),$document_root);
+		$document_root = str_replace("[website_idhash_4]",$this->id_hash($page_form->id,1),$document_root);
 
 		// get the ID of the client
 		if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {
@@ -442,7 +468,12 @@ class page_action extends tform_actions {
 			// Set the values for document_root, system_user and system_group
 			$system_user = $app->db->quote('web'.$this->id);
 			$system_group = $app->db->quote('client'.$client_id);
-			$document_root = $app->db->quote(str_replace("[client_id]",$client_id,$document_root));
+			$document_root = str_replace("[client_id]",$client_id,$document_root);
+			$document_root = str_replace("[client_idhash_1]",$this->id_hash($client_id,1),$document_root);
+			$document_root = str_replace("[client_idhash_2]",$this->id_hash($client_id,2),$document_root);
+			$document_root = str_replace("[client_idhash_3]",$this->id_hash($client_id,3),$document_root);
+			$document_root = str_replace("[client_idhash_4]",$this->id_hash($client_id,4),$document_root);
+			$document_root = $app->db->quote($document_root);
 
 			$sql = "UPDATE web_domain SET system_user = '$system_user', system_group = '$system_group', document_root = '$document_root' WHERE domain_id = ".$this->id;
 			//$sql = "UPDATE web_domain SET system_user = '$system_user', system_group = '$system_group' WHERE domain_id = ".$this->id;