What is the best practice for renaming GET URLs in PHP?

When renaming GET URLs in PHP, it is best practice to use a router or a routing system to handle the mapping of URLs to specific PHP files or functions. This helps in organizing and managing the URLs in a more structured way, making it easier to maintain and update the codebase. By using a router, you can define routes for different URLs and map them to corresponding PHP files or functions, allowing for cleaner and more readable code.

// Example of using a simple router to rename GET URLs in PHP

// Define routes for different URLs
$routes = [
    '/' => 'home.php',
    '/about' => 'about.php',
    '/contact' => 'contact.php'
];

// Get the current URL
$currentUrl = $_SERVER['REQUEST_URI'];

// Check if the current URL is defined in the routes
if (array_key_exists($currentUrl, $routes)) {
    // Include the corresponding PHP file
    include $routes[$currentUrl];
} else {
    // Handle 404 error or redirect to a default page
    echo 'Page not found';
}