How can PHP developers securely disable access to .htaccess files in a file manager service?

To securely disable access to .htaccess files in a file manager service, PHP developers can use the following code snippet to deny access to these files by checking the requested file name and returning a 403 Forbidden error if it matches ".htaccess".

<?php
$requestedFile = $_SERVER['REQUEST_URI'];
if(strpos($requestedFile, '.htaccess') !== false) {
    header('HTTP/1.0 403 Forbidden');
    exit;
}
?>