# Momentum SPA · /public_html/.htaccess
# Send all non-asset, non-api requests to index.html so React Router (or our internal view state) handles them.

Options -MultiViews
RewriteEngine On

# Force HTTPS once AutoSSL is active (uncomment to enable)
# RewriteCond %{HTTPS} off
# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Don't rewrite API requests — they have their own .htaccess
RewriteRule ^api/ - [L]

# Real files & directories: serve as-is
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Everything else -> SPA
RewriteRule ^ index.html [L]

# Long-cache hashed assets (Vite/CRA outputs filenames with content hashes)
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css                  "access plus 1 year"
    ExpiresByType application/javascript    "access plus 1 year"
    ExpiresByType image/svg+xml             "access plus 1 month"
    ExpiresByType image/png                 "access plus 1 month"
    ExpiresByType image/jpg                 "access plus 1 month"
    ExpiresByType image/webp                "access plus 1 month"
    ExpiresByType font/woff2                "access plus 1 year"
    ExpiresByType text/html                 "access plus 0 seconds"
</IfModule>

<IfModule mod_headers.c>
    # Don't cache index.html (so deploys take effect immediately)
    <FilesMatch "index\.html$">
        Header set Cache-Control "no-cache, no-store, must-revalidate"
    </FilesMatch>
    # Security headers
    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>

# Compression
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/json image/svg+xml
</IfModule>

Options -Indexes
