diff --git a/system/src/Grav/Common/Uri.php b/system/src/Grav/Common/Uri.php index 1bfd73f96..34fc4a372 100644 --- a/system/src/Grav/Common/Uri.php +++ b/system/src/Grav/Common/Uri.php @@ -87,13 +87,18 @@ class Uri // process params $uri = $this->processParams($uri, $config->get('system.param_sep')); - $regex = '/(\/(?:'.$language->getAvailablekeys().')\/).*/'; + $regex = '/(\/('.$language->getAvailablekeys().'\/)).*/'; - if (preg_match($regex, $uri, $matches)) { - $uri = preg_replace("/\\".$matches[1]."/", '', $matches[0], 1); - $lang = $matches[2]; + // if languages set + if ($language->defaultKey()) { + if (preg_match($regex, $uri, $matches)) { + $lang = $matches[2]; + } else { + $lang = $language->getDefaultKey(); + } } + // split the URL and params $bits = parse_url($uri);