diff --git a/lib/private/helper.php b/lib/private/helper.php
index da3d3cd1c6ea55f0042f9e14adafcee55a851281..5ce0c2e59acaa3f1049cfcb3fe8fdc384826ed8d 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -125,8 +125,12 @@ class OC_Helper {
 	 * Returns a absolute url to the given service.
 	 */
 	public static function linkToPublic($service, $add_slash = false) {
-		return self::linkToAbsolute('', 'public.php') . '?service=' . $service
-		. (($add_slash && $service[strlen($service) - 1] != '/') ? '/' : '');
+		return OC::$server->getURLGenerator()->getAbsoluteURL(
+			self::linkTo(
+				'', 'public.php') . '?service=' . $service
+				. (($add_slash && $service[strlen($service) - 1] != '/') ? '/' : ''
+			)
+		);
 	}
 
 	/**