Options -Indexes
DirectoryIndex index.php

# Apache/PHP-FPM strips the Authorization header by default; pass it to PHP for Bearer API keys.
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
# No SetEnvIf here: since 2026-10-29 the host rejects it in .htaccess (HTTP 500 for the whole folder).
# The rewrite rule above already passes the header (bootstrap.php also reads REDIRECT_HTTP_AUTHORIZATION).
<FilesMatch "^(README\.md|router\.php)$">
    Require all denied
</FilesMatch>
<IfModule mod_headers.c>
    Header always set X-Content-Type-Options "nosniff"
    Header always set Referrer-Policy "same-origin"
</IfModule>

<IfModule mod_mime.c>
    AddType application/manifest+json .webmanifest
</IfModule>

# Versioned asset URLs (?v=commit) may be cached for a long time.
# sw.js is the exception: a service worker is only updated when this URL is revalidated.
<IfModule mod_headers.c>
    <FilesMatch "\.(css|js|png|svg|webp|woff2?)$">
        Header set Cache-Control "public, max-age=31536000, immutable"
    </FilesMatch>
    <Files "sw.js">
        Header set Cache-Control "no-cache"
    </Files>
    <Files "manifest.webmanifest">
        Header set Cache-Control "no-cache"
    </Files>
</IfModule>
