What role does the server type (e.g., Apache vs. nginx) play in protecting PHP pages from external access?

The server type, such as Apache or nginx, plays a role in protecting PHP pages from external access by controlling access to files and directories. By configuring the server properly, you can prevent unauthorized users from directly accessing PHP files and potentially exposing sensitive information.

// Add this code to the .htaccess file in the root directory to restrict access to PHP files
<FilesMatch "\.php$">
    Order allow,deny
    Deny from all
</FilesMatch>