diff --git a/apps/contacts/appinfo/remote.php b/apps/contacts/appinfo/remote.php
index ef50e4ad39ffe9040a7db755c906d2725202c5fa..5add3bc6889651a4a5e3c661eecfbba9e0ad4467 100644
--- a/apps/contacts/appinfo/remote.php
+++ b/apps/contacts/appinfo/remote.php
@@ -22,8 +22,8 @@
 
 OCP\App::checkAppEnabled('contacts');
 
-if(substr($_SERVER["REQUEST_URI"],0,strlen(OC::$APPSWEBROOT . '/apps/contacts/carddav.php')) == OC::$APPSWEBROOT . '/apps/contacts/carddav.php'){
-	$baseuri = OC::$APPSWEBROOT . '/apps/contacts/carddav.php';
+if(substr($_SERVER["REQUEST_URI"],0,strlen(OC_App::getAppWebPath('contacts').'/carddav.php')) == OC_App::getAppWebPath('contacts').'/carddav.php'){
+	$baseuri = OC_App::getAppWebPath('contacts').'/carddav.php';
 }
 
 // only need authentication apps
diff --git a/core/js/js.js b/core/js/js.js
index 89a20a529f348e8806c41285e177781ff77df242..a1ad0c77184cddebf33b56698bd7364afa031c77 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -31,7 +31,7 @@ t.cache={};
 
 OC={
 	webroot:oc_webroot,
-	appswebroot:oc_appswebroot,
+	appswebroots:oc_appswebroots,
 	currentUser:(typeof oc_current_user!=='undefined')?oc_current_user:false,
 	coreApps:['', 'admin','log','search','settings','core','3rdparty'],
 	/**
@@ -63,10 +63,8 @@ OC={
 				link+= file;
 			}
 		}else if(file.substring(file.length-3) != 'php' && !isCore){
-			link=OC.appswebroot;
-			link+='/';
-			link+='apps/';
-			link+=app+'/';
+			link=OC.appswebroots[app];
+			link+='/'+app+'/';
 			if(type){
 				link+=type+'/';
 			}
diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php
index 7f5a4d50fc6b827d9f84019f32c7f03e545c0f71..7a9689177184567f37ae627cf395a99f33c81ebd 100644
--- a/core/templates/layout.guest.php
+++ b/core/templates/layout.guest.php
@@ -12,7 +12,7 @@
 		<?php endforeach; ?>
 		<script type="text/javascript">
 			var oc_webroot = '<?php echo OC::$WEBROOT; ?>';
-			var oc_appswebroot = '<?php echo OC::$APPSWEBROOT; ?>';
+			var oc_appswebroots = <?php echo $_['apps_paths'] ?>;
 		</script>
 		<?php if (!defined('DEBUG') || !DEBUG): ?>
 		<script type="text/javascript" src="<?php echo OC_Helper::linkToRemote('core.js', false) ?>"></script>
diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php
index 5f00a884a04b23e4e93c0824164101ab752ca24d..91cfa1a87a110a19433575ec69a36688045a56e8 100644
--- a/core/templates/layout.user.php
+++ b/core/templates/layout.user.php
@@ -12,8 +12,7 @@
 		<?php endforeach; ?>
 		<script type="text/javascript">
 			var oc_webroot = '<?php echo OC::$WEBROOT; ?>';
-			var oc_appswebroot = '<?php //echo OC::$APPSWEBROOT; ?>';
-			// TODO: PATH
+			var oc_appswebroots = <?php echo $_['apps_paths'] ?>;
 			var oc_current_user = '<?php echo OC_User::getUser() ?>';
 		</script>
 		<?php if (!defined('DEBUG') || !DEBUG): ?>
diff --git a/lib/template.php b/lib/template.php
index fdd608fdc7af76485cee1dd0b8457db118c91b02..6fe07102034e9e72bdf83ebd5bb8f9b6b1a554d9 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -383,6 +383,11 @@ class OC_Template{
 			}else{
 				$page = new OC_Template( "core", "layout.guest" );
 			}
+			$apps_paths = array();
+			foreach(OC_App::getEnabledApps() as $app){
+				$apps_paths[$app] = OC_App::getAppWebPath($app);
+			}
+			$page->assign( 'apps_paths', str_replace('\\/', '/',json_encode($apps_paths)) ); // Ugly unescape slashes waiting for better solution
 
 			// Read the selected theme from the config file
 			$theme=OC_Config::getValue( "theme" );