diff --git a/apps/bookmarks/templates/list.php b/apps/bookmarks/templates/list.php
index fdd2b19f79ac0dcee2ce737cdb57c26a975c66e2..84436ae7409f3e470033dbf4ec1915352edbef21 100644
--- a/apps/bookmarks/templates/list.php
+++ b/apps/bookmarks/templates/list.php
@@ -20,7 +20,7 @@
 <div id="firstrun" style="display: none;">
 	<?php
 		echo $l->t('You have no bookmarks');
-		require_once(OC::$APPSROOT . '/apps/bookmarks/templates/bookmarklet.php');
+		require_once(OC_App::getAppPath('bookmarks') .'/templates/bookmarklet.php');
 		createBookmarklet(); 
 	?>
 </div>
diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php
index 8f6c029007fc59b4e3b3954bfba06c13e6667faa..5f00a884a04b23e4e93c0824164101ab752ca24d 100644
--- a/core/templates/layout.user.php
+++ b/core/templates/layout.user.php
@@ -12,7 +12,8 @@
 		<?php endforeach; ?>
 		<script type="text/javascript">
 			var oc_webroot = '<?php echo OC::$WEBROOT; ?>';
-			var oc_appswebroot = '<?php echo OC::$APPSWEBROOT; ?>';
+			var oc_appswebroot = '<?php //echo OC::$APPSWEBROOT; ?>';
+			// TODO: PATH
 			var oc_current_user = '<?php echo OC_User::getUser() ?>';
 		</script>
 		<?php if (!defined('DEBUG') || !DEBUG): ?>
diff --git a/lib/app.php b/lib/app.php
index 13b6617b23ef9999672b3fa961f4e83b03308fbd..5883a29bb0282a9286a1458b8a1b59b182e97b66 100755
--- a/lib/app.php
+++ b/lib/app.php
@@ -328,11 +328,23 @@ class OC_App{
 	*/
 	public static function getAppPath($appid) {
 		foreach(OC::$APPSROOTS as $dir) {
-			if(file_exists($dir.'/'.$appid)) {
-				return $dir.'/'.$appid;
+			if(file_exists($dir['path'].'/'.$appid)) {
+				return $dir['path'].'/'.$appid;
+			}
+		}
+		return false;
+	}
+
+	/**
+	* Get the path for the given app on the access
+	* If the app is defined in multiple directory, the first one is taken. (false if not found)
+	*/
+	public static function getAppWebPath($appid) {
+		foreach(OC::$APPSROOTS as $dir) {
+			if(file_exists($dir['path'].'/'.$appid)) {
+				return $dir['web'].'/'.$appid;
 			}
 		}
-// 		OC_Log::write('core','Unable to find app "'.$appid.'"',OC_Log::ERROR);
 		return false;
 	}
 
@@ -477,9 +489,9 @@ class OC_App{
 	public static function getAllApps(){
 		$apps=array();
 		foreach(OC::$APPSROOTS as $apps_dir) {
-			$dh=opendir($apps_dir);
+			$dh=opendir($apps_dir['path']);
 			while($file=readdir($dh)){
-				if(substr($file,0,1)!='.' and is_file($apps_dir.'/'.$file.'/appinfo/app.php')){
+				if(substr($file,0,1)!='.' and is_file($apps_dir['path'].'/'.$file.'/appinfo/app.php')){
 					$apps[]=$file;
 				}
 			}
diff --git a/lib/base.php b/lib/base.php
index b494bbcabc584ce4aaa1bf5b5e84cdc5440e8b80..131485961ad0fa16cced5a24520a9badda933669 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -55,13 +55,9 @@ class OC{
 	 */
 	public static $THIRDPARTYWEBROOT = '';
 	/**
-	 * The installation path of the apps folder on the server (e.g. /srv/http/owncloud)
+	 * The installation path array of the apps folder on the server (e.g. /srv/http/owncloud) 'real' and web path in 'web'
 	 */
 	public static $APPSROOTS = array();
-	/**
-	 * the root path of the apps folder for http requests (e.g. owncloud)
-	 */
-	public static $APPSWEBROOT = '';
 	/*
 	 * requested app
 	 */
@@ -168,27 +164,31 @@ class OC{
 
 		// search the apps folder
 		if(OC_Config::getValue('appsroot', '')<>''){
-			OC::$APPSROOTS=explode(':',OC_Config::getValue('appsroot', ''));
-			OC::$APPSWEBROOT=OC_Config::getValue('appsurl', '');
-		}elseif(file_exists(OC::$SERVERROOT.'/apps')){
-			OC::$APPSROOTS= array(OC::$SERVERROOT.'/apps');
- 			OC::$APPSWEBROOT=OC::$WEBROOT;
-		}
-		if(file_exists(OC::$SERVERROOT.'/../apps')){
-			OC::$APPSROOTS[] = rtrim(realpath(OC::$SERVERROOT.'/../apps'), '/');
-// 			OC::$APPSWEBROOT=rtrim(dirname(OC::$WEBROOT), '/');
+			$real_a = explode(':',OC_Config::getValue('appsroot', ''));
+			$web_a = explode(':',OC_Config::getValue('appsurl', ''));
+			foreach($real_a as $k => $path) {
+				if(!isset($web_a[$k])){
+					echo("Apps root and appsurl not mathing. You need to have the same number of paths");
+					exit;
+				}
+				OC::$APPSROOTS[] = array('path'=> $path, 'web' => $web_a[$k]);
+			}
 		}
+
 		if(empty(OC::$APPSROOTS)){
 			echo("apps directory not found! Please put the ownCloud apps folder in the ownCloud folder or the folder above. You can also configure the location in the config.php file.");
 			exit;
 		}
+		$paths = array();
+		foreach( OC::$APPSROOTS as $path)
+			$paths[] = $path['path'];
 
 		// set the right include path
 		set_include_path(
 			OC::$SERVERROOT.'/lib'.PATH_SEPARATOR.
 			OC::$SERVERROOT.'/config'.PATH_SEPARATOR.
 			OC::$THIRDPARTYROOT.'/3rdparty'.PATH_SEPARATOR.
-			implode(OC::$APPSROOTS,PATH_SEPARATOR).PATH_SEPARATOR.
+			implode($paths,PATH_SEPARATOR).PATH_SEPARATOR.
 			get_include_path().PATH_SEPARATOR.
 			OC::$SERVERROOT
 		);
@@ -292,6 +292,7 @@ class OC{
 				require_once(OC::$APPSROOT . '/apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE);
 			}
 		}else{
+			die();
 			header('HTTP/1.0 404 Not Found');
 			exit;
 		}
diff --git a/lib/helper.php b/lib/helper.php
index 72ae98222d93eee6203e74833de21be68f7d9ff6..550bf9771e455632ba04e9a85e91df691b3ab65a 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -48,7 +48,7 @@ class OC_Helper {
 					$urlLinkTo =  OC::$WEBROOT . '/?app=' . $app;
 					$urlLinkTo .= ($file!='index.php')?'&getfile=' . urlencode($file):'';
 				}else{
-					$urlLinkTo =  OC::$APPSWEBROOT . '/apps/' . $app . $file;
+					$urlLinkTo =  OC_App::getAppWebPath($app) . $file;
 				}
 			}
 			else{
@@ -151,7 +151,7 @@ class OC_Helper {
 		if( file_exists( OC::$SERVERROOT."/themes/$theme/apps/$app/img/$image" )){
 			return OC::$WEBROOT."/themes/$theme/apps/$app/img/$image";
 		}elseif( file_exists(OC_App::getAppPath($app)."/img/$image" )){
-			return OC::$APPSWEBROOT."/apps/$app/img/$image";
+			return OC_App::getAppWebPath($app)."/img/$image";
 		}elseif( !empty( $app ) and file_exists( OC::$SERVERROOT."/themes/$theme/$app/img/$image" )){
 			return OC::$WEBROOT."/themes/$theme/$app/img/$image";
 		}elseif( !empty( $app ) and file_exists( OC::$SERVERROOT."/$app/img/$image" )){
diff --git a/lib/template.php b/lib/template.php
index a354d58a4b11e69e6a6fc21141a24d07caf107f3..e6525ec6336c08dd96042d097e61acc39fad0284 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -415,8 +415,8 @@ class OC_Template{
 					$append = false;
 					foreach( OC::$APPSROOTS as $apps_dir)
 					{
-						if($page->appendIfExist('jsfiles', $apps_dir, OC::$APPSWEBROOT.'/apps/', "$script$fext.js" , true)) { $append =true; break; }
-						elseif($page->appendIfExist('jsfiles', $apps_dir, OC::$APPSWEBROOT.'/apps/', "$script.js", true )) { $append =true; break; }
+						if($page->appendIfExist('jsfiles', $apps_dir['path'], $apps_dir['web'], "$script$fext.js" , true)) { $append =true; break; }
+						elseif($page->appendIfExist('jsfiles', $apps_dir['path'], $apps_dir['web'], "$script.js", true )) { $append =true; break; }
 					}
 					if(! $append) {
 						echo('js file not found: script:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);
@@ -443,8 +443,8 @@ class OC_Template{
 					$append = false;
 					foreach( OC::$APPSROOTS as $apps_dir)
 					{
-						if($page->appendIfExist('cssfiles', $apps_dir, OC::$APPSWEBROOT, "$style$fext.css", true)) { $append =true; break; }
-						elseif($page->appendIfExist('cssfiles', $apps_dir, OC::$APPSWEBROOT, "$style.css", true )) { $append =true; break; }
+						if($page->appendIfExist('cssfiles', $apps_dir['path'], $apps_dir['web'], "$style$fext.css", true)) { $append =true; break; }
+						elseif($page->appendIfExist('cssfiles', $apps_dir['path'], $apps_dir['web'], "$style.css", true )) { $append =true; break; }
 					}
 					if(! $append) {
 						echo('css file not found: style:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);