# Static asset caching (assets are byte-identical; caching only)
<IfModule mod_expires.c>
    ExpiresActive On
    # Long-lived: fonts & images rarely change
    ExpiresByType font/woff2             "access plus 1 year"
    ExpiresByType font/woff              "access plus 1 year"
    ExpiresByType image/svg+xml          "access plus 1 year"
    ExpiresByType image/webp             "access plus 1 year"
    ExpiresByType image/png              "access plus 1 year"
    ExpiresByType image/x-icon           "access plus 1 year"
    # Shorter: css/js change on deploy (no content-hash in filenames)
    ExpiresByType text/css               "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
    ExpiresByType text/javascript        "access plus 1 month"
</IfModule>
<IfModule mod_headers.c>
    <FilesMatch "\.(woff2?|svg|webp|png|jpe?g|gif|ico)$">
        Header set Cache-Control "public, max-age=31536000, immutable"
    </FilesMatch>
    <FilesMatch "\.(css|js)$">
        Header set Cache-Control "public, max-age=2592000"
    </FilesMatch>
</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}]

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

    # Allow Apple Pay domain verification (must come before front-controller rule)
    RewriteRule ^\.well-known/ - [L]

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