diff --git a/lib/router.php b/lib/router.php
index dbcaff4026e5181946dc763c5f7c3e7d5dbeb199..eca59d6dc3b2effd9b953b165894572a86c2b206 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -54,7 +54,11 @@ class OC_Router {
 	}
 
     	public function match($url) {
-		$context = new RequestContext($_SERVER['REQUEST_URI'], $_SERVER['REQUEST_METHOD']);
+		$baseUrl = OC_Helper::linkTo('', 'index.php');
+		$method = $_SERVER['REQUEST_METHOD'];
+		$host = OC_Request::serverHost();
+		$schema = OC_Request::serverProtocol();
+		$context = new RequestContext($baseUrl, $method, $host, $schema);
 		$matcher = new UrlMatcher($this->root, $context);
 		$parameters = $matcher->match($url);
 		if (isset($parameters['action'])) {