# Fig & Owl — Apache config for the static site.
# Only used on an Apache host; Cloudflare Pages and other hosts ignore it.

# Serve the site's own 404 page
ErrorDocument 404 /404.html

# Do not let Apache guess file variants
Options -MultiViews

<IfModule mod_rewrite.c>
  RewriteEngine On

  # Clean URLs: /menu and /menu/ both serve /menu/index.html.
  # Only rewrites when a matching folder index actually exists, so real
  # files and images are always served untouched.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{DOCUMENT_ROOT}/$1/index.html -f
  RewriteRule ^(.+?)/?$ /$1/index.html [L]

  # Force HTTPS (uncomment once the host has an SSL certificate)
  # RewriteCond %{HTTPS} !=on
  # RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

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

# Caching: hashed assets long, HTML always fresh
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType text/css "access plus 1 year"
  ExpiresByType application/javascript "access plus 1 year"
  ExpiresByType font/woff2 "access plus 1 year"
  ExpiresByType image/webp "access plus 1 month"
  ExpiresByType image/jpeg "access plus 1 month"
  ExpiresByType image/png "access plus 1 month"
  ExpiresByType image/svg+xml "access plus 1 month"
  ExpiresByType text/html "access plus 0 seconds"
</IfModule>
