diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php
index 21ab52c2fdb3c19c08f179dfa57fe58eb334e154..b36012843cd76562d435378a01088eea21459dea 100644
--- a/server/plugins-available/nginx_plugin.inc.php
+++ b/server/plugins-available/nginx_plugin.inc.php
@@ -388,14 +388,14 @@ class nginx_plugin {
 			if($data['new']['web_folder'] != ''){
 				if(substr($data['new']['web_folder'],0,1) == '/') $data['new']['web_folder'] = substr($data['new']['web_folder'],1);
 				if(substr($data['new']['web_folder'],-1) == '/') $data['new']['web_folder'] = substr($data['new']['web_folder'],0,-1);
+				$web_folder .= '/'.$data['new']['web_folder'];
 			}
-			$web_folder .= '/'.$data['new']['web_folder'];
 
 			if($data['old']['web_folder'] != ''){
 				if(substr($data['old']['web_folder'],0,1) == '/') $data['old']['web_folder'] = substr($data['old']['web_folder'],1);
 				if(substr($data['old']['web_folder'],-1) == '/') $data['old']['web_folder'] = substr($data['old']['web_folder'],0,-1);
+				$old_web_folder .= '/'.$data['old']['web_folder'];
 			}
-			$old_web_folder .= '/'.$data['old']['web_folder'];
 		}
 		if($data['new']['type'] == 'vhostsubdomain' || $data['new']['type'] == 'vhostalias') {
 			// new one
@@ -882,7 +882,7 @@ class nginx_plugin {
 				//$app->system->chmod($data['new']['document_root'].'/webdav',0710);
 				$app->system->chmod($data['new']['document_root'].'/private', 0710);
 				$app->system->chmod($data['new']['document_root'].'/ssl', 0755);
-				if($web_folder != 'web') $app->system->chmod($data['new']['document_root'].'/'.$web_folder, 0751);
+				if($web_folder != 'web') $app->system->chmod($data['new']['document_root'].'/'.$web_folder, $web_folder_permission);
 
 				// make tmp directory writable for nginx and the website users
 				$app->system->chmod($data['new']['document_root'].'/tmp', 0770);