diff --git a/remote.php b/remote.php
index 44b85f762f58d11b57e343c55300e6975274ea96..63a45321eb03668d5b8cde48b3d49bad5e9213ed 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 (!$pos = strpos($path_info, '/', 1)) {
 	$pos = strlen($path_info);
@@ -22,4 +22,4 @@ $app=$parts[2];
 OC_App::loadApp($app);
 
 $baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/';
-require_once(OC::$APPSROOT . $file);
\ No newline at end of file
+require_once(OC::$APPSROOT . $file);