# Apache rewrite rules for TanStack Router (SPA mode).
# Update RewriteBase if the app is not served from /dashboard/malawi-today-news/

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /dashboard/malawi-today-news/

  DirectoryIndex index.html

  # Serve existing files and directories as-is
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} -f [OR]
  RewriteCond %{REQUEST_FILENAME} -d
  RewriteRule ^ - [L]

  # All other routes fall back to the SPA shell
  RewriteRule ^ index.html [L]
</IfModule>

# Cache static assets
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType text/css "access plus 1 year"
  ExpiresByType application/javascript "access plus 1 year"
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
</IfModule>
