# ---- startup.mplinktech.com (static export on cPanel / Apache) ----

# Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

DirectoryIndex index.html
ErrorDocument 404 /404.html
AddDefaultCharset UTF-8

# ---- Speed: compress text files (Brotli when available, otherwise gzip)
<IfModule mod_brotli.c>
  AddOutputFilterByType BROTLI_COMPRESS text/html text/css text/plain text/xml application/javascript application/json application/ld+json application/manifest+json image/svg+xml
</IfModule>
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/javascript application/json application/ld+json application/manifest+json image/svg+xml
</IfModule>

# ---- Speed: browser caching. Build files in /_next/static have a hash in their name, so they never change.
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType text/html "access plus 0 seconds"
  ExpiresByType application/xml "access plus 1 day"
  ExpiresByType application/manifest+json "access plus 1 day"
  ExpiresByType text/css "access plus 1 year"
  ExpiresByType application/javascript "access plus 1 year"
  ExpiresByType image/png "access plus 1 month"
  ExpiresByType image/webp "access plus 1 month"
  ExpiresByType image/x-icon "access plus 1 month"
</IfModule>
<IfModule mod_headers.c>
  <FilesMatch "\.(?:css|js|woff2)$">
    Header set Cache-Control "public, max-age=31536000, immutable"
  </FilesMatch>
  <FilesMatch "\.html$">
    Header set Cache-Control "no-cache"
  </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"
  Header always set Permissions-Policy "camera=(), microphone=(), geolocation=()"
  # Uncomment once HTTPS works on every address of this subdomain (browsers remember it for 6 months):
  # Header always set Strict-Transport-Security "max-age=15552000"
</IfModule>
