What are some best practices for structuring modular websites with CleanUrls in PHP?

When structuring modular websites with CleanUrls in PHP, it is important to organize your code into separate modules or components to keep it clean and maintainable. One best practice is to use a front controller pattern to route all requests through a single entry point, which can then dispatch the request to the appropriate module based on the URL. This helps to keep your code organized and makes it easier to add new modules or make changes in the future.

// index.php
$request_uri = $_SERVER['REQUEST_URI'];

// Route the request to the appropriate module based on the URL
if ($request_uri === '/module1') {
    include 'module1.php';
} elseif ($request_uri === '/module2') {
    include 'module2.php';
} else {
    // Handle 404 error
    http_response_code(404);
    echo '404 Page Not Found';
}