Options -Indexes
ServerSignature Off

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Keep application internals and deployment material private.
    RewriteRule ^(?:app|vendor|writable)(?:/|$) - [F,L,NC]
    RewriteRule ^(?:\.env(?:\..*)?|composer\.(?:json|lock)|spark|preload\.php|stallionsfa_database\.sql|INSTALLATION\.txt)$ - [F,L,NC]

    # Preserve Let's Encrypt/AutoSSL validation files.
    RewriteRule ^\.well-known/acme-challenge/ - [L]

    # Serve real assets directly; route all other requests through CodeIgniter.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index.php [L,QSA]

    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

<FilesMatch "^(?:\.env(?:\..*)?|composer\.(?:json|lock)|spark|preload\.php|stallionsfa_database\.sql|INSTALLATION\.txt)$">
    Require all denied
</FilesMatch>

<IfModule mod_headers.c>
    Header always set X-Content-Type-Options "nosniff"
    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>
