Are there best practices for allowing exceptions in access restrictions for certain folders in PHP?

When implementing access restrictions for certain folders in PHP, it is important to consider allowing exceptions for specific folders that require different levels of access. One way to achieve this is by checking the requested folder path against a list of exceptions and granting access accordingly. This can be done by modifying the access control logic to allow access if the requested folder matches any of the exceptions.

$restrictedFolders = ['/secure-folder', '/admin-folder'];
$requestedFolder = $_SERVER['REQUEST_URI'];

if (!in_array($requestedFolder, $restrictedFolders)) {
    // Allow access to the requested folder
    // Your code to handle access to the folder goes here
} else {
    // Deny access to the requested folder
    // Your code to handle denied access goes here
}