How can you optimize the code for setting a default main page in PHP to improve performance?

To optimize the code for setting a default main page in PHP, you can use a conditional statement to check if a specific page is requested and redirect to the default main page if not. This can help improve performance by reducing unnecessary processing and database queries.

<?php
// Check if a specific page is requested
if(!isset($_GET['page'])) {
    // Redirect to the default main page
    header('Location: index.php');
    exit();
}

// Rest of your code for handling the requested page
?>