diff --git a/remote.php b/remote.php
index b1be50f36a7d4d9382d58f6ef31030be91ff5c2e..0c5804221bb3645a1f099de74c6659eb153aafd9 100644
--- a/remote.php
+++ b/remote.php
@@ -5,7 +5,7 @@ require_once('lib/base.php');
 if (array_key_exists('PATH_INFO', $_SERVER)){
 	$path_info = $_SERVER['PATH_INFO'];
 }else{
-	$path_info = substr($_SERVER['PHP_SELF'], strpos($_SERVER['PHP_SELF'], basename(__FILE__)) + strlen(basename(__FILE__)));
+	$path_info = substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME']));
 }
 if ($path_info === false) {
 	OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND);