routes[$path] = [ 'controller' => $controller, 'action' => $action, ]; } public function dispatch(string $uri): void { // Normalize: strip query string and trailing slash $path = parse_url($uri, PHP_URL_PATH); $path = rtrim($path, '/') ?: '/'; // Direct match if (isset($this->routes[$path])) { $this->execute($this->routes[$path]); return; } // Legacy .html redirect (301) if (preg_match('#^/(impressum|datenschutz)\.html$#', $path, $m)) { header('Location: /' . $m[1], true, 301); exit; } // 404 http_response_code(404); echo '