'home.php', '/new' => 'new_twt.php', '/add' => 'add_feed.php', '/following' => 'following.php', '/refresh' => 'load_twt_files.php', '/login' => 'login.php', '/logout' => 'logout.php', '/profile' => 'profile.php', '/profile' => 'profile.php', //'/profile/([a-zA-Z0-9_-]+)' => 'profile.php', '/conv/([a-zA-Z0-9]{7})' => 'conv.php', // matches only twtHash of exactly 7 alphanumeric characters '/post/([a-zA-Z0-9]{7})' => 'post.php', // matches only twtHash of exactly 7 alphanumeric characters '/twtmention' => 'twtmention_endpoint.php', '/webmention' => 'webmention_endpoint.php', ]; // Loop through the defined routes and try to match the request URI foreach ($routes as $pattern => $action) { if (preg_match('#^' . $pattern . '$#', $path, $matches)) { // Extract any matched parameters (e.g., username) if(!empty($matches[1])) { //array_shift($matches); $id = $matches[1]; } // Load the corresponding action (view) require __DIR__ . $viewDir . $action; exit; // Stop processing further routes } } // If no matching route is found, handle as a 404 http_response_code(404); echo "