<IfModule mod_headers.c>
    # Enforce HTTPS (HSTS) - Tells browsers to only connect via HTTPS
    Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"

    # Prevent Clickjacking
    Header always set X-Frame-Options "SAMEORIGIN"

    # Prevent MIME type sniffing
    Header always set X-Content-Type-Options "nosniff"

    # Control referrer information
    Header always set Referrer-Policy "strict-origin-when-cross-origin"

    # Content Security Policy — deliberately NOT set here.
    #
    # The policy is built per-request by App\Http\Middleware\SecurityHeaders
    # from config/security.php, because some pages have to widen it at runtime
    # (the Pterodactyl console opens a websocket to a Wings daemon on the
    # customer's own node, a host no static allowlist can know). A browser
    # intersects two CSP headers on one response, so a static copy here would
    # silently cancel every runtime addition and break those pages.
    #
    # To add sources for this install, use CSP_CONNECT_SRC (and friends) in
    # .env — see config/security.php.

    # Permissions Policy (Restrict access to browser features)
    Header always set Permissions-Policy "geolocation=(), microphone=(), camera=(), payment=()"
</IfModule>

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Handle X-XSRF-Token Header
    RewriteCond %{HTTP:x-xsrf-token} .
    RewriteRule .* - [E=HTTP_X_XSRF_TOKEN:%{HTTP:X-XSRF-Token}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
