diff --git a/apps/files/index.php b/apps/files/index.php
index 104cf1a55d322ffcad11544fb60d82fc50cef5fb..434e98c6ea847a8b2f2316c570685be84b1446d4 100644
--- a/apps/files/index.php
+++ b/apps/files/index.php
@@ -92,7 +92,7 @@ foreach (explode('/', $dir) as $i) {
 $list = new OCP\Template('files', 'part.list', '');
 $list->assign('files', $files, false);
 $list->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=', false);
-$list->assign('downloadURL', OCP\Util::linkTo('files', 'download.php') . '?file=', false);
+$list->assign('downloadURL', OCP\Util::linkToRoute('download', array('file' => '/')), false);
 $list->assign('disableSharing', false);
 $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
 $breadcrumbNav->assign('breadcrumb', $breadcrumb, false);
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 72b353b48c2c31446cda8793263240aaba79a326..c176057c86dde147a88e9f27688ea32e9eb8f1f9 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -15,7 +15,7 @@ var FileList={
 			extension=false;
 		}
 		html+='<td class="filename" style="background-image:url('+img+')"><input type="checkbox" />';
-		html+='<a class="name" href="download.php?file='+$('#dir').val().replace(/</, '&lt;').replace(/>/, '&gt;')+'/'+escapeHTML(name)+'"><span class="nametext">'+escapeHTML(basename);
+		html+='<a class="name" href="' +OC.Router.generate('download', { file: $('#dir').val()+'/'+name }) +'"><span class="nametext">'+escapeHTML(basename);
 		if(extension){
 			html+='<span class="extension">'+escapeHTML(extension)+'</span>';
 		}
diff --git a/lib/public/util.php b/lib/public/util.php
index 968ca891b4c83cc160e7d836a9fda55eaad04876..5f6ede4460e85eaafccb014029cfccedaa56ca22 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -147,6 +147,20 @@ class Util {
 		return \OC_Helper::linkToPublic($service);
 	}
 
+	/**
+	 * @brief Creates an url using a defined route
+	 * @param $route
+	 * @param array $parameters
+	 * @return
+	 * @internal param array $args with param=>value, will be appended to the returned url
+	 * @returns the url
+	 *
+	 * Returns a url to the given app and file.
+	 */
+	public static function linkToRoute( $route, $parameters = array() ) {
+		return \OC_Helper::linkToRoute($route, $parameters);
+	}
+
 	/**
 	* @brief Creates an url
 	* @param string $app app