diff --git a/interface/lib/plugins/sites_web_vhost_subdomain_plugin.inc.php b/interface/lib/plugins/sites_web_vhost_subdomain_plugin.inc.php
index e28c184eef9f42eb621dad9b127c200250c15bf1..c4170334b8dc236e138b1ce235c7c4f2294de58b 100644
--- a/interface/lib/plugins/sites_web_vhost_subdomain_plugin.inc.php
+++ b/interface/lib/plugins/sites_web_vhost_subdomain_plugin.inc.php
@@ -44,25 +44,27 @@ class sites_web_vhost_subdomain_plugin {
     */
 	function sites_web_vhost_subdomain_edit($event_name, $page_form) {
 		global $app, $conf;
+		
+		if(isset($page_form->dataRecord["parent_domain_id"]) && $page_form->dataRecord["parent_domain_id"] != $page_form->oldDataRecord["parent_domain_id"]) {
+			// Get configuration for the web system
+			$app->uses("getconf");
+			$web_config = $app->getconf->get_server_config($app->functions->intval($page_form->dataRecord['server_id']), 'web');
 
-		// Get configuration for the web system
-		$app->uses("getconf");
-		$web_config = $app->getconf->get_server_config($app->functions->intval($page_form->dataRecord['server_id']), 'web');
+			$parent_domain = $app->db->queryOneRecord("SELECT * FROM `web_domain` WHERE `domain_id` = '" . $app->functions->intval($page_form->dataRecord['parent_domain_id']) . "'");
 
-		$parent_domain = $app->db->queryOneRecord("SELECT * FROM `web_domain` WHERE `domain_id` = '" . $app->functions->intval($page_form->dataRecord['parent_domain_id']) . "'");
+			// Set the values for document_root, system_user and system_group
+			$system_user = $app->db->quote($parent_domain['system_user']);
+			$system_group = $app->db->quote($parent_domain['system_group']);
+			$document_root = $app->db->quote($parent_domain['document_root']);
+			$php_open_basedir = str_replace("[website_path]/web", $document_root.'/'.$page_form->dataRecord['web_folder'], $web_config["php_open_basedir"]);
+			$php_open_basedir = str_replace("[website_domain]/web", $page_form->dataRecord['domain'].'/'.$page_form->dataRecord['web_folder'], $php_open_basedir);
+			$php_open_basedir = str_replace("[website_path]", $document_root, $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($parent_domain['allow_override']);
 
-		// Set the values for document_root, system_user and system_group
-		$system_user = $app->db->quote($parent_domain['system_user']);
-		$system_group = $app->db->quote($parent_domain['system_group']);
-		$document_root = $app->db->quote($parent_domain['document_root']);
-		$php_open_basedir = str_replace("[website_path]/web", $document_root.'/'.$page_form->dataRecord['web_folder'], $web_config["php_open_basedir"]);
-		$php_open_basedir = str_replace("[website_domain]/web", $page_form->dataRecord['domain'].'/'.$page_form->dataRecord['web_folder'], $php_open_basedir);
-		$php_open_basedir = str_replace("[website_path]", $document_root, $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($parent_domain['allow_override']);
-
-		$sql = "UPDATE web_domain SET sys_groupid = ".$app->functions->intval($parent_domain['sys_groupid']).",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);
+			$sql = "UPDATE web_domain SET sys_groupid = ".$app->functions->intval($parent_domain['sys_groupid']).",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);
+		}
 	}
 
 }
diff --git a/interface/web/sites/web_vhost_subdomain_edit.php b/interface/web/sites/web_vhost_subdomain_edit.php
index 14f6b8eac2c8df9560d24e42c18ccba178821655..37359a25d501f2fc18fc21a494bb51ae7c83250a 100644
--- a/interface/web/sites/web_vhost_subdomain_edit.php
+++ b/interface/web/sites/web_vhost_subdomain_edit.php
@@ -606,24 +606,27 @@ class page_action extends tform_actions {
 
 	function onAfterUpdate() {
 		global $app, $conf;
-
-		// Get configuration for the web system
-		$app->uses("getconf");
-		$web_rec = $app->tform->getDataRecord($this->id);
-		$web_config = $app->getconf->get_server_config($app->functions->intval($web_rec["server_id"]), 'web');
-
-		// Set the values for document_root, system_user and system_group
-		$system_user = $app->db->quote($this->parent_domain_record['system_user']);
-		$system_group = $app->db->quote($this->parent_domain_record['system_group']);
-		$document_root = $app->db->quote($this->parent_domain_record['document_root']);
-		$php_open_basedir = str_replace("[website_path]/web", $document_root.'/'.$web_rec['web_folder'], $web_config["php_open_basedir"]);
-		$php_open_basedir = str_replace("[website_domain]/web", $web_rec['domain'].'/'.$web_rec['web_folder'], $php_open_basedir);
-		$php_open_basedir = str_replace("[website_path]", $document_root, $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($this->parent_domain_record['allow_override']);
-
-		$sql = "UPDATE web_domain SET sys_groupid = ".$app->functions->intval($this->parent_domain_record['sys_groupid']).",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 = ".$this->id;
-		$app->db->query($sql);
+		
+		//* Update settings when parent domain gets changed
+		if(isset($this->dataRecord["parent_domain_id"]) && $this->dataRecord["parent_domain_id"] != $this->oldDataRecord["parent_domain_id"]) {
+			// Get configuration for the web system
+			$app->uses("getconf");
+			$web_rec = $app->tform->getDataRecord($this->id);
+			$web_config = $app->getconf->get_server_config($app->functions->intval($web_rec["server_id"]), 'web');
+
+			// Set the values for document_root, system_user and system_group
+			$system_user = $app->db->quote($this->parent_domain_record['system_user']);
+			$system_group = $app->db->quote($this->parent_domain_record['system_group']);
+			$document_root = $app->db->quote($this->parent_domain_record['document_root']);
+			$php_open_basedir = str_replace("[website_path]/web", $document_root.'/'.$web_rec['web_folder'], $web_config["php_open_basedir"]);
+			$php_open_basedir = str_replace("[website_domain]/web", $web_rec['domain'].'/'.$web_rec['web_folder'], $php_open_basedir);
+			$php_open_basedir = str_replace("[website_path]", $document_root, $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($this->parent_domain_record['allow_override']);
+
+			$sql = "UPDATE web_domain SET sys_groupid = ".$app->functions->intval($this->parent_domain_record['sys_groupid']).",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 = ".$this->id;
+			$app->db->query($sql);
+		}
 	}
 
 }