From ce6b3b1f5f4c2b79099cbdd09a242e04822a0c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Grennerat?= Date: Sat, 11 Feb 2023 11:40:55 +0100 Subject: [PATCH] strtok the resques url before right trimming the / The request_url should firstly be split to remove everything after the first ``?``: > $request_url = strtok($request_url, '?'); And only then, the $request_url should be right trimmed to remove the last ``/``: > $request_url = rtrim($request_url, '/'); Theses two lines were inverted. --- router.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/router.php b/router.php index d296abc..2feb955 100644 --- a/router.php +++ b/router.php @@ -28,8 +28,8 @@ function route($route, $path_to_include){ exit(); } $request_url = filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL); - $request_url = rtrim($request_url, '/'); $request_url = strtok($request_url, '?'); + $request_url = rtrim($request_url, '/'); $route_parts = explode('/', $route); $request_url_parts = explode('/', $request_url); array_shift($route_parts);