diff --git a/lib/functions.php b/lib/functions.php
index a7f9f3a0b2fed0d65983d918c85c1ce6e1902f31..9986104b50e54b45edd408434135630715a7ab4f 100644
--- a/lib/functions.php
+++ b/lib/functions.php
@@ -1429,7 +1429,7 @@ function get_route($route = '')
         foreach ($pieces as $index => $piece) {
             $trail .= ($trail ? '/' : '') . $piece;
             if ($dispatcher->file_exists($trail . '.php')) {
-                $route = 'dispatch.php/' . $trail . (isset($pieces[$index+1]) ? '/' . $pieces[$index+1] : '');
+                $route = 'dispatch.php/' . $trail . (!empty($pieces[$index+1]) ? '/' . $pieces[$index+1] : '');
             }
         }
     }