diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index abe0bf12aa3e8dbc306a99b640b618f1c7eed695..d313434358b450c56ec679b8ea49abe7ebf116c1 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -985,7 +985,14 @@ class SimpleSAML_Utilities {
 			$base = substr($base, 0, -1);
 		}
 
-		$ret = $base;
+		/* Check for absolute path. */
+		if(substr($path, 0, 1) === '/') {
+			/* Absolute path. */
+			$ret = '/';
+		} else {
+			/* Path relative to base. */
+			$ret = $base;
+		}
 
 		$path = explode('/', $path);
 		foreach($path as $d) {