DirectoryIndex index.php

# Disable directory browsing
Options -Indexes

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Redirect to index.php if file/dir doesn't exist
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index.php [L,QSA]
</IfModule>

# Block public access to sensitive system, config, backup, and log files
<FilesMatch "(\.(env|ini|log|sql|bak|conf|git|sh|md)|error_log|composer\.(json|lock)|\.user\.ini|php\.ini)$">
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order allow,deny
        Deny from all
    </IfModule>
</FilesMatch>

# Security Headers
<IfModule mod_headers.c>
    Header set X-Content-Type-Options "nosniff"
    Header set X-Frame-Options "SAMEORIGIN"
    Header set X-XSS-Protection "1; mode=block"
    Header set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>
